Zelda Classic Coverage Report


Directory: src/
File: src/zc/script_drawing.cpp
Date: 2023-08-19 03:06:52
Exec Total Coverage
Lines: 1319 5111 25.8%
Functions: 47 103 45.6%
Branches: 568 2631 21.6%

Line Branch Exec Source
1 // This program is free software; you can redistribute it and/or modify it under the terms of the
2 // modified version 3 of the GNU General Public License. See License.txt for details.
3
4 //! ritate_sprite_trans doesn't seem to be supported by or allegro header !?
5
6 //glibc 2.28 and later require this: -Z
7 #ifdef __GNUG__
8 #define ALLEGRO_NO_FIX_ALIASES
9 #endif
10
11 #define LOG_BMPBLIT_LEVEL 0
12 #include "base/qrs.h"
13 #include "base/dmap.h"
14 #include "base/zc_alleg.h"
15 #include "zc/script_drawing.h"
16 #include "zc/rendertarget.h"
17 #include "zc/maps.h"
18 #include "tiles.h"
19 #include "zc/zelda.h"
20 #include "zc/ffscript.h"
21 #include "base/util.h"
22 #include "subscr.h"
23 #include "drawing.h"
24 #include "base/mapscr.h"
25 #include "base/misctypes.h"
26 using namespace util;
27 extern FFScript FFCore;
28 extern ZModule zcm;
29 extern refInfo *ri;
30 extern script_bitmaps scb;
31 #include <stdio.h>
32 #include <fstream>
33
34 #define DegtoFix(d) ((d)*0.7111111111111)
35 #define RadtoFix(d) ((d)*40.743665431525)
36
37 inline double sd_log2( double n )
38 {
39 // log(n)/log(2) is log2.
40 double v = log( (double)n ) / log( (double)2 );
41 return v;
42 }
43
44 inline bool isPowerOfTwo(int32_t n)
45 {
46 if(n==0)
47 return false;
48
49 return (ceil(sd_log2(n)) == floor(sd_log2(n)));
50 }
51
52
53
54 template<class T> inline
55 210792 fixed degrees_to_fixed(T d)
56 {
57 210792 return ftofix(DegtoFix(d));
58 }
59 template<class T> inline
60 fixed radians_to_fixed(T d)
61 {
62 return ftofix(RadtoFix(d));
63 }
64
65 BITMAP* ScriptDrawingBitmapPool::_parent_bmp = 0;
66
67 class TileHelper
68 {
69 public:
70
71 17420 static void OldPutTile(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, byte skiprows=0)
72 {
73 // Past the end of the tile page?
74
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17420 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17420 if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
75 {
76 byte w2=(tile+w)%TILES_PER_ROW;
77 OldPutTile(_Dest, tile, x, y, w-w2, h, color, flip);
78 OldPutTile(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip);
79 return;
80 }
81
82
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 17420 times.
17420 switch(flip)
83 {
84 case 1:
85 for(int32_t j=0; j<h; j++)
86 for(int32_t k=w-1; k>=0; k--)
87 oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip);
88
89 break;
90
91 case 2:
92 for(int32_t j=h-1; j>=0; j--)
93 for(int32_t k=0; k<w; k++)
94 oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip);
95
96 break;
97
98 case 3:
99 for(int32_t j=h-1; j>=0; j--)
100 for(int32_t k=w-1; k>=0; k--)
101 oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip);
102
103 break;
104
105 17420 case 0:
106 default:
107
2/2
✓ Branch 0 taken 17420 times.
✓ Branch 1 taken 17420 times.
34840 for(int32_t j=0; j<h; j++)
108
2/2
✓ Branch 0 taken 17420 times.
✓ Branch 1 taken 17420 times.
34840 for(int32_t k=0; k<w; k++)
109 34840 oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip);
110
111 17420 break;
112 }
113 17420 }
114
115 2611995 static void OverTile(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, byte skiprows=0)
116 {
117 2611995 overtileblock16(_Dest,tile,x,y,w,h,color,flip,skiprows);
118 2611995 }
119
120 static void OverTileCloaked(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t flip, byte skiprows=0)
121 {
122 if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
123 {
124 byte w2=(tile+w)%TILES_PER_ROW;
125 OverTileCloaked(_Dest, tile, x, y, w-w2, h, flip);
126 OverTileCloaked(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, flip);
127 return;
128 }
129
130 switch(flip)
131 {
132 case 1:
133 for(int32_t j=0; j<h; j++)
134 for(int32_t k=w-1; k>=0; k--)
135 overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, flip);
136
137 break;
138
139 case 2:
140 for(int32_t j=h-1; j>=0; j--)
141 for(int32_t k=0; k<w; k++)
142 overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, flip);
143
144 break;
145
146 case 3:
147 for(int32_t j=h-1; j>=0; j--)
148 for(int32_t k=w-1; k>=0; k--)
149 overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, flip);
150
151 break;
152
153 default:
154 for(int32_t j=0; j<h; j++)
155 for(int32_t k=0; k<w; k++)
156 overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, flip);
157
158 break;
159 }
160 }
161
162 48644 static void OverTileTranslucent(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, int32_t opacity, byte skiprows=0)
163 {
164
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48644 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48644 if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
165 {
166 byte w2=(tile+w)%TILES_PER_ROW;
167 OverTileTranslucent(_Dest, tile, x, y, w-w2, h, color, flip, opacity);
168 OverTileTranslucent(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip, opacity);
169 return;
170 }
171
172
1/4
✓ Branch 0 taken 48644 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48644 switch(flip)
173 {
174 case 1:
175 for(int32_t j=0; j<h; j++)
176 for(int32_t k=w-1; k>=0; k--)
177 overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip, opacity);
178
179 break;
180
181 case 2:
182 for(int32_t j=h-1; j>=0; j--)
183 for(int32_t k=0; k<w; k++)
184 overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip, opacity);
185
186 break;
187
188 case 3:
189 for(int32_t j=h-1; j>=0; j--)
190 for(int32_t k=w-1; k>=0; k--)
191 overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip, opacity);
192
193 break;
194
195 default:
196
2/2
✓ Branch 0 taken 67033 times.
✓ Branch 1 taken 48644 times.
115677 for(int32_t j=0; j<h; j++)
197
2/2
✓ Branch 0 taken 193855 times.
✓ Branch 1 taken 67033 times.
260888 for(int32_t k=0; k<w; k++)
198 260888 overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip, opacity);
199
200 48644 break;
201 }
202 48644 }
203
204 static void PutTileTranslucent(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, int32_t opacity, byte skiprows=0)
205 {
206 if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
207 {
208 byte w2=(tile+w)%TILES_PER_ROW;
209 PutTileTranslucent(_Dest, tile, x, y, w-w2, h, color, flip, opacity);
210 PutTileTranslucent(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip, opacity);
211 return;
212 }
213
214 switch(flip)
215 {
216 case 1:
217 for(int32_t j=0; j<h; j++)
218 for(int32_t k=w-1; k>=0; k--)
219 puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip, opacity);
220
221 break;
222
223 case 2:
224 for(int32_t j=h-1; j>=0; j--)
225 for(int32_t k=0; k<w; k++)
226 puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip, opacity);
227
228 break;
229
230 case 3:
231 for(int32_t j=h-1; j>=0; j--)
232 for(int32_t k=w-1; k>=0; k--)
233 puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip, opacity);
234
235 break;
236
237 default:
238 for(int32_t j=0; j<h; j++)
239 for(int32_t k=0; k<w; k++)
240 puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip, opacity);
241
242 break;
243 }
244 }
245 };
246
247
248
249
250 2290034 void do_rectr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
251 {
252 //sdci[1]=layer
253 //sdci[2]=x
254 //sdci[3]=y
255 //sdci[4]=x2
256 //sdci[5]=y2
257 //sdci[6]=color
258 //sdci[7]=scale factor
259 //sdci[8]=rotation anchor x
260 //sdci[9]=rotation anchor y
261 //sdci[10]=rotation angle
262 //sdci[11]=fill
263 //sdci[12]=opacity
264
1/2
✓ Branch 0 taken 2290034 times.
✗ Branch 1 not taken.
2290034 if(sdci[7]==0) //scale
265 {
266 return;
267 }
268
269 2290034 int32_t x1=sdci[2]/10000;
270 2290034 int32_t y1=sdci[3]/10000;
271 2290034 int32_t x2=sdci[4]/10000;
272 2290034 int32_t y2=sdci[5]/10000;
273
274
1/2
✓ Branch 0 taken 2290034 times.
✗ Branch 1 not taken.
2290034 if(x1>x2)
275 {
276 zc_swap(x1,x2);
277 }
278
279
1/2
✓ Branch 0 taken 2290034 times.
✗ Branch 1 not taken.
2290034 if(y1>y2)
280 {
281 zc_swap(y1,y2);
282 }
283
284
2/2
✓ Branch 0 taken 2288953 times.
✓ Branch 1 taken 1081 times.
2290034 if(sdci[7] != 10000)
285 {
286 1081 int32_t w=x2-x1+1;
287 1081 int32_t h=y2-y1+1;
288 1081 int32_t w2=(w*sdci[7])/10000;
289 1081 int32_t h2=(h*sdci[7])/10000;
290 1081 x1=x1-((w2-w)/2);
291 1081 x2=x2+((w2-w)/2);
292 1081 y1=y1-((h2-h)/2);
293 1081 y2=y2+((h2-h)/2);
294 1081 }
295
296 2290034 int32_t color=sdci[6]/10000;
297
298
2/2
✓ Branch 0 taken 2253975 times.
✓ Branch 1 taken 36059 times.
2290034 if(sdci[12]/10000<=127) //translucent
299 {
300 36059 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
301 36059 }
302
303
2/2
✓ Branch 0 taken 82060 times.
✓ Branch 1 taken 2207974 times.
2290034 if(sdci[10]==0) //no rotation
304 {
305
2/2
✓ Branch 0 taken 706744 times.
✓ Branch 1 taken 1501230 times.
2207974 if(sdci[11]) //filled
306 {
307 1501230 rectfill(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
308 1501230 }
309 else //outline
310 {
311 706744 rect(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
312 }
313 2207974 }
314 else //rotate
315 {
316 int32_t xy[16];
317 82060 int32_t rx=sdci[8]/10000;
318 82060 int32_t ry=sdci[9]/10000;
319 82060 fixed ra1=itofix(sdci[10]%10000)/10000;
320 82060 fixed ra2=itofix(sdci[10]/10000);
321 82060 fixed ra=ra1+ra2;
322 82060 ra = (ra/360)*256;
323
324 82060 fixed fcosa = fixcos(ra);
325 82060 fixed fsina = fixsin(ra);
326
327 82060 xy[ 0]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry))); //x1
328 82060 xy[ 1]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry))); //y1
329 82060 xy[ 2]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y1 - ry))); //x2
330 82060 xy[ 3]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y1 - ry))); //y1
331 82060 xy[ 4]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry))); //x2
332 82060 xy[ 5]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry))); //y2
333 82060 xy[ 6]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y2 - ry))); //x1
334 82060 xy[ 7]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y2 - ry))); //y2
335 82060 xy[ 8]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry + 1))); //x1
336 82060 xy[ 9]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry + 1))); //y1
337 82060 xy[10]=xoffset+rx + fixtoi((fcosa * (x2 - rx - 1) - fsina * (y1 - ry))); //x2
338 82060 xy[11]=yoffset+ry + fixtoi((fsina * (x2 - rx - 1) + fcosa * (y1 - ry))); //y1
339 82060 xy[12]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry - 1))); //x2
340 82060 xy[13]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry - 1))); //y2
341 82060 xy[14]=xoffset+rx + fixtoi((fcosa * (x1 - rx + 1) - fsina * (y2 - ry))); //x1
342 82060 xy[15]=yoffset+ry + fixtoi((fsina * (x1 - rx + 1) + fcosa * (y2 - ry))); //y2
343
344
1/2
✓ Branch 0 taken 82060 times.
✗ Branch 1 not taken.
82060 if(sdci[11]) //filled
345 {
346 82060 polygon(bmp, 4, xy, color);
347 82060 }
348 else //outline
349 {
350 line(bmp, xy[0], xy[1], xy[10], xy[11], color);
351 line(bmp, xy[2], xy[3], xy[12], xy[13], color);
352 line(bmp, xy[4], xy[5], xy[14], xy[15], color);
353 line(bmp, xy[6], xy[7], xy[ 8], xy[ 9], color);
354 }
355 }
356
357 2290034 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
358 2290034 }
359
360 void do_framer(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
361 {
362 //sdci[1]=layer
363 //sdci[2]=x
364 //sdci[3]=y
365 //sdci[4]=tile
366 //sdci[5]=cset
367 //sdci[6]=width
368 //sdci[7]=height
369 //sdci[8]=overlay
370 //sdci[9]=opacity
371
372 int32_t x=sdci[2]/10000;
373 int32_t y=sdci[3]/10000;
374
375 int32_t tile=sdci[4]/10000;
376 int32_t cs=sdci[5]/10000;
377 int32_t w=sdci[6]/10000;
378 int32_t h=sdci[7]/10000;
379 bool overlay=sdci[8];
380 bool trans=(sdci[9]/10000<=127);
381
382 frame2x2(bmp, x + xoffset, y + yoffset, tile, cs, w, h, 0, overlay, trans);
383 }
384
385
386
387 1130854 void do_circler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
388 {
389 //sdci[1]=layer
390 //sdci[2]=x
391 //sdci[3]=y
392 //sdci[4]=radius
393 //sdci[5]=color
394 //sdci[6]=scale factor
395 //sdci[7]=rotation anchor x
396 //sdci[8]=rotation anchor y
397 //sdci[9]=rotation angle
398 //sdci[10]=fill
399 //sdci[11]=opacity
400
1/2
✓ Branch 0 taken 1130854 times.
✗ Branch 1 not taken.
1130854 if(sdci[6]==0) //scale
401 {
402 return;
403 }
404
405 1130854 int32_t x1=sdci[2]/10000;
406 1130854 int32_t y1=sdci[3]/10000;
407 1130854 qword r=sdci[4];
408
409
1/2
✓ Branch 0 taken 1130854 times.
✗ Branch 1 not taken.
1130854 if(sdci[6] != 10000)
410 {
411 r*=sdci[6];
412 r/=10000;
413 }
414
415 1130854 r/=10000;
416 1130854 int32_t color=sdci[5]/10000;
417
418
2/2
✓ Branch 0 taken 959832 times.
✓ Branch 1 taken 171022 times.
1130854 if(sdci[11]/10000<=127) //translucent
419 {
420 171022 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
421 171022 }
422
423
5/6
✓ Branch 0 taken 58575 times.
✓ Branch 1 taken 1072279 times.
✓ Branch 2 taken 1344 times.
✓ Branch 3 taken 57231 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1344 times.
1130854 if(sdci[9]!=0&&(sdci[2]!=sdci[7]||sdci[3]!=sdci[8])) //rotation
424 {
425 int32_t xy[2];
426 57231 int32_t rx=sdci[7]/10000;
427 57231 int32_t ry=sdci[8]/10000;
428 57231 fixed ra1=itofix(sdci[9]%10000)/10000;
429 57231 fixed ra2=itofix(sdci[9]/10000);
430 57231 fixed ra=ra1+ra2;
431 57231 ra = (ra/360)*256;
432
433 57231 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
434 57231 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
435 57231 x1=xy[0];
436 57231 y1=xy[1];
437 57231 }
438
439
2/2
✓ Branch 0 taken 1113840 times.
✓ Branch 1 taken 17014 times.
1130854 if(sdci[10]) //filled
440 {
441 1113840 circlefill(bmp, x1+xoffset, y1+yoffset, r, color);
442 1113840 }
443 else //outline
444 {
445 17014 circle(bmp, x1+xoffset, y1+yoffset, r, color);
446 }
447
448 1130854 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
449 1130854 }
450
451
452 void do_arcr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
453 {
454 //sdci[1]=layer
455 //sdci[2]=x
456 //sdci[3]=y
457 //sdci[4]=radius
458 //sdci[5]=start angle
459 //sdci[6]=end angle
460 //sdci[7]=color
461 //sdci[8]=scale factor
462 //sdci[9]=rotation anchor x
463 //sdci[10]=rotation anchor y
464 //sdci[11]=rotation angle
465 //sdci[12]=closed
466 //sdci[13]=fill
467 //sdci[14]=opacity
468
469 if(sdci[8]==0) //scale
470 {
471 return;
472 }
473
474 int32_t cx=sdci[2]/10000;
475 int32_t cy=sdci[3]/10000;
476 qword r=sdci[4];
477
478 if(sdci[8] != 10000)
479 {
480 r*=sdci[8];
481 r/=10000;
482 }
483
484 r/=10000;
485
486 int32_t color=sdci[7]/10000;
487
488 fixed ra1=itofix(sdci[11]%10000)/10000;
489 fixed ra2=itofix(sdci[11]/10000);
490 fixed ra=ra1+ra2;
491 ra = (ra/360)*256;
492
493
494 fixed a1=itofix(sdci[5]%10000)/10000;
495 fixed a2=itofix(sdci[5]/10000);
496 fixed sa=a1+a2;
497 sa = (sa/360)*256;
498
499 a1=itofix(sdci[6]%10000)/10000;
500 a2=itofix(sdci[6]/10000);
501 fixed ea=a1+a2;
502 ea = (ea/360)*256;
503
504 if(sdci[11]!=0) //rotation
505 {
506 int32_t rx=sdci[9]/10000;
507 int32_t ry=sdci[10]/10000;
508
509 cx=rx + fixtoi((fixcos(ra) * (cx - rx) - fixsin(ra) * (cy - ry))); //x1
510 cy=ry + fixtoi((fixsin(ra) * (cx - rx) + fixcos(ra) * (cy - ry))); //y1
511 ea-=ra;
512 sa-=ra;
513 }
514
515 int32_t fx=cx+fixtoi(fixcos(-(ea+sa)/2)*r/2);
516 int32_t fy=cy+fixtoi(fixsin(-(ea+sa)/2)*r/2);
517
518 if(sdci[12]) //closed
519 {
520 if(sdci[13]) //filled
521 {
522 clear_bitmap(prim_bmp);
523 arc(prim_bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
524 line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color);
525 line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color);
526 int fillx = zc_max(0,fx)+xoffset;
527 int filly = zc_max(0,fy)+yoffset;
528 zprint2("Screen->Arc fill at prim_bmp (%d,%d) - 512x512\n", fillx, filly);
529 floodfill(prim_bmp, fillx, filly, color);
530
531 if(sdci[14]/10000<=127) //translucent
532 {
533 draw_trans_sprite(bmp, prim_bmp, 0,0);
534 }
535 else
536 {
537 draw_sprite(bmp, prim_bmp, 0,0);
538 }
539 }
540 else
541 {
542 arc(bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
543 line(bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color);
544 line(bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color);
545 }
546 }
547 else
548 {
549 if(sdci[14]/10000<=127) //translucent
550 {
551 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
552 }
553
554 arc(bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
555 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
556 }
557 }
558
559
560 1850 void do_ellipser(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
561 {
562 //sdci[1]=layer
563 //sdci[2]=x
564 //sdci[3]=y
565 //sdci[4]=radiusx
566 //sdci[5]=radiusy
567 //sdci[6]=color
568 //sdci[7]=scale factor
569 //sdci[8]=rotation anchor x
570 //sdci[9]=rotation anchor y
571 //sdci[10]=rotation angle
572 //sdci[11]=fill
573 //sdci[12]=opacity
574
575
1/2
✓ Branch 0 taken 1850 times.
✗ Branch 1 not taken.
1850 if(sdci[7]==0) //scale
576 {
577 return;
578 }
579
580 1850 int32_t x1=sdci[2]/10000;
581 1850 int32_t y1=sdci[3]/10000;
582 1850 int32_t radx=sdci[4]/10000;
583 1850 radx*=sdci[7]/10000;
584 1850 int32_t rady=sdci[5]/10000;
585 1850 rady*=sdci[7]/10000;
586 1850 int32_t color=sdci[6]/10000;
587 1850 float rotation = sdci[10]/10000;
588
589 1850 int32_t rx=sdci[8]/10000;
590 1850 int32_t ry=sdci[9]/10000;
591 1850 fixed ra1=itofix(sdci[10]%10000)/10000;
592 1850 fixed ra2=itofix(sdci[10]/10000);
593 1850 fixed ra=ra1+ra2;
594 1850 ra = (ra/360)*256;
595
596 int32_t xy[2];
597 1850 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
598 1850 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
599 1850 x1=xy[0];
600 1850 y1=xy[1];
601
602
6/8
✓ Branch 0 taken 1746 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 1687 times.
✓ Branch 3 taken 59 times.
✓ Branch 4 taken 1687 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1687 times.
1850 if(radx<1||rady<1||radx>255||rady>255) return;
603
604 1687 BITMAP* bitty = script_drawing_commands.AquireSubBitmap(radx*2+1, rady*2+1);
605
606
2/2
✓ Branch 0 taken 1630 times.
✓ Branch 1 taken 57 times.
1687 if(sdci[11]) //filled
607 {
608
609
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 606 times.
1630 if(sdci[12]/10000<128) //translucent
610 {
611 1024 clear_bitmap(prim_bmp);
612
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color);
613 1024 rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
614 1024 draw_trans_sprite(bmp, prim_bmp, 0, 0);
615 1024 }
616 else // no opacity
617 {
618
1/2
✓ Branch 0 taken 606 times.
✗ Branch 1 not taken.
606 ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color);
619 606 rotate_sprite(bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
620 }
621 1630 }
622 else //not filled
623 {
624
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 43 times.
57 if(sdci[12]/10000<128) //translucent
625 {
626 14 clear_bitmap(prim_bmp);
627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 ellipse(bitty, radx, rady, radx, rady, color==0?255:color);
628 14 rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
629 14 draw_trans_sprite(bmp, prim_bmp, 0, 0);
630 14 }
631 else // no opacity
632 {
633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 ellipse(bitty, radx, rady, radx, rady, color==0?255:color);
634 43 rotate_sprite(bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
635 }
636 }
637
638 // Since 0 is the transparent color, the stuff above will fail if the ellipse color is also 0.
639 // Instead, it uses color 255 and replaces it afterward. That'll also screw up color 255 around
640 // the ellipse, but it shouldn't be used anyway.
641
1/2
✓ Branch 0 taken 1687 times.
✗ Branch 1 not taken.
1687 if(color==0)
642 {
643 // This is very slow, so check the smallest possible square
644 int32_t endx=zc_min(bmp->w-1, x1+zc_max(radx, rady));
645 int32_t endy=zc_min(bmp->h-1, y1+zc_max(radx, rady));
646
647 for(int32_t y=zc_max(0, y1-zc_max(radx, rady)); y<=endy; y++)
648 for(int32_t x=zc_max(0, x1-zc_max(radx, rady)); x<=endx; x++)
649 if(getpixel(bmp, x, y)==255)
650 putpixel(bmp, x, y, 0);
651 }
652
653 1687 script_drawing_commands.ReleaseSubBitmap(bitty);
654 1850 }
655
656
657 937839 void do_liner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
658 {
659 //sdci[1]=layer
660 //sdci[2]=x
661 //sdci[3]=y
662 //sdci[4]=x2
663 //sdci[5]=y2
664 //sdci[6]=color
665 //sdci[7]=scale factor
666 //sdci[8]=rotation anchor x
667 //sdci[9]=rotation anchor y
668 //sdci[10]=rotation angle
669 //sdci[11]=opacity
670
1/2
✓ Branch 0 taken 937839 times.
✗ Branch 1 not taken.
937839 if(sdci[7]==0) //scale
671 {
672 return;
673 }
674
675 937839 int32_t x1=sdci[2]/10000;
676 937839 int32_t y1=sdci[3]/10000;
677 937839 int32_t x2=sdci[4]/10000;
678 937839 int32_t y2=sdci[5]/10000;
679
680
2/2
✓ Branch 0 taken 489517 times.
✓ Branch 1 taken 448322 times.
937839 if(sdci[7] != 10000)
681 {
682 448322 int32_t w=x2-x1+1;
683 448322 int32_t h=y2-y1+1;
684 448322 int32_t w2=int32_t(w*((double)sdci[7]/10000.0));
685 448322 int32_t h2=int32_t(h*((double)sdci[7]/10000.0));
686 448322 x1=x1-((w2-w)/2);
687 448322 x2=x2+((w2-w)/2);
688 448322 y1=y1-((h2-h)/2);
689 448322 y2=y2+((h2-h)/2);
690 448322 }
691
692 937839 int32_t color=sdci[6]/10000;
693
694
1/2
✓ Branch 0 taken 937839 times.
✗ Branch 1 not taken.
937839 if(sdci[11]/10000<=127) //translucent
695 {
696 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
697 }
698
699
1/2
✓ Branch 0 taken 937839 times.
✗ Branch 1 not taken.
937839 if(sdci[10]!=0) //rotation
700 {
701 int32_t xy[4];
702 int32_t rx=sdci[8]/10000;
703 int32_t ry=sdci[9]/10000;
704 fixed ra1=itofix(sdci[10]%10000)/10000;
705 fixed ra2=itofix(sdci[10]/10000);
706 fixed ra=ra1+ra2;
707
708 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
709 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
710 xy[ 2]=rx + fixtoi((fixcos(ra) * (x2 - rx) - fixsin(ra) * (y2 - ry))); //x2
711 xy[ 3]=ry + fixtoi((fixsin(ra) * (x2 - rx) + fixcos(ra) * (y2 - ry))); //y2
712 x1=xy[0];
713 y1=xy[1];
714 x2=xy[2];
715 y2=xy[3];
716 }
717
718 937839 line(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
719 937839 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
720 937839 }
721
722 void do_linesr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
723 {
724 //sdci[1]=layer
725 //sdci[2]=array[10] = { x, y, x2, y2, colour, scale, rx, ry, angle, opacity }
726
727 //sdci[2]=x
728 //sdci[3]=y
729 //sdci[4]=x2
730 //sdci[5]=y2
731 //sdci[6]=color
732 //sdci[7]=scale factor
733 //sdci[8]=rotation anchor x
734 //sdci[9]=rotation anchor y
735 //sdci[10]=rotation angle
736 //sdci[11]=opacity
737 //if(sdci[7]==0) //scale
738 //{
739 // return;
740 //}
741
742 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
743
744 if(!v_ptr)
745 {
746 al_trace("Screen->PutPixels: Vector pointer is null! Internal error. \n");
747 return;
748 }
749
750 std::vector<int32_t> &v = *v_ptr;
751
752 if(v.empty())
753 return;
754 //Z_scripterrlog("PutPixels reached line %d\n", 983);
755
756 int32_t* pos = &v[0];
757 int32_t sz = v.size();
758
759 for ( int32_t q = 0; q < sz; q+=10 )
760 {
761
762 int32_t x1 = v.at(q);
763 Z_scripterrlog("Lines( x1 ) is: %d\n", x1);
764 int32_t y1 = v.at(q+1);
765 Z_scripterrlog("Lines( x2 ) is: %d\n", y1);
766 int32_t x2 = v.at(q+2);
767 Z_scripterrlog("Lines( x2 ) is: %d\n", x2);
768 int32_t y2 = v.at(q+3);
769 Z_scripterrlog("Lines( y2 ) is: %d\n", y2);
770 int32_t color = v.at(q+4);
771 Z_scripterrlog("Lines( colour ) is: %d\n", color);
772 Z_scripterrlog("Lines( scale ) is: %d\n", v.at(q+5));
773 if (v.at(q+5) == 0) { Z_scripterrlog("Lines() aborting due to scale\n"); return; }//scale
774
775 if( v.at(q+5) != 10000)
776 {
777 int32_t w=x2-x1+1;
778 int32_t h=y2-y1+1;
779 int32_t w2=int32_t(w*((double)v.at(q+5)));
780 int32_t h2=int32_t(h*((double)v.at(q+5)));
781 x1=x1-((w2-w)/2);
782 x2=x2+((w2-w)/2);
783 y1=y1-((h2-h)/2);
784 y2=y2+((h2-h)/2);
785 }
786
787
788 Z_scripterrlog("Lines( opacity ) is: %d\n", v.at(q+9));
789 if(v.at(q+9) <= 127) //translucent
790 {
791 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
792 }
793 else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
794 Z_scripterrlog("Lines( rotation ) is: %d\n", v.at(q+8));
795 Z_scripterrlog("Lines( rot_x ) is: %d\n", v.at(q+6));
796 Z_scripterrlog("Lines( rot_x ) is: %d\n", v.at(q+7));
797 if( v.at(q+8) !=0 ) //rotation
798 {
799 int32_t xy[4];
800
801 int32_t rx = v.at(q+6);
802
803 int32_t ry = v.at(q+7);
804
805 fixed ra1=itofix(v.at(q+8) % 1);
806 fixed ra2=itofix(v.at(q+8));
807 fixed ra=ra1+ra2;
808
809 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
810 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
811 xy[ 2]=rx + fixtoi((fixcos(ra) * (x2 - rx) - fixsin(ra) * (y2 - ry))); //x2
812 xy[ 3]=ry + fixtoi((fixsin(ra) * (x2 - rx) + fixcos(ra) * (y2 - ry))); //y2
813 x1=xy[0];
814 y1=xy[1];
815 x2=xy[2];
816 y2=xy[3];
817 }
818 Z_scripterrlog("Lines( xofs ) is: %d\n", xoffset);
819 Z_scripterrlog("Lines( yofs ) is: %d\n", yoffset);
820 line(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
821 }
822 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
823 }
824
825 void do_polygonr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
826 {
827 //sdci[1]=layer
828 //sdci[2]=point count
829 //sdci[3]array[]
830 //sdci[4] = colour
831 //sdci[5] = opacity
832
833 int32_t col = sdci[4]/10000;
834 int32_t op = sdci[5]/10000;
835
836 //bool brokenOffset= ( (get_er(er_BITMAPOFFSET)!=0) || (get_qr(qr_BITMAPOFFSETFIX)!=0) );
837 //Z_scripterrlog("Broken offset rule for Polygon() is: %s\n", brokenOffset ? "ON" : "OFF");
838 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
839
840 if(!v_ptr)
841 {
842 al_trace("Screen->Polygon: Vector pointer is null! Internal error. \n");
843 return;
844 }
845
846 std::vector<int32_t> &v = *v_ptr;
847
848 if(v.empty())
849 return;
850 //Z_scripterrlog("PutPixels reached line %d\n", 983);
851
852 int32_t* pos = &v[0];
853 int32_t sz = v.size();
854 int32_t numpoints = (sdci[2]/10000);
855 if(sz & 1) --sz; //even amount only
856 if(numpoints > sz/2) //cap to array
857 numpoints = sz/2;
858 if(numpoints < 1)
859 return; //Don't draw 0 or negative point count
860
861 //Fix the draw Y offset. -Z 20th June, 2019
862 for ( int32_t q = 1; q < sz; q+=2 )
863 {
864 pos[q] += yoffset;
865 }
866 if(op <= 127) //translucent
867 {
868 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
869 }
870 else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
871
872 polygon(bmp, numpoints, (int32_t*)pos, col);
873 //polygon(bmp, (sdci[2]/10000), &v, col);
874 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
875 }
876
877 void bmp_do_polygonr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
878 {
879 //sdci[1]=layer
880 //sdci[2]=point count
881 //sdci[3]array[]
882 //sdci[4] = colour
883 //sdci[5] = opacity
884
885 int32_t col = sdci[4]/10000;
886 int32_t op = sdci[5]/10000;
887
888 if ( sdci[17] <= 0 )
889 {
890 Z_scripterrlog("bitmap->Rectangle() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
891 return;
892 }
893 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
894 if ( refbmp == NULL ) return;
895
896 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
897
898 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
899
900 if(!v_ptr)
901 {
902 al_trace("Screen->Polygon: Vector pointer is null! Internal error. \n");
903 return;
904 }
905
906 std::vector<int32_t> &v = *v_ptr;
907
908 if(v.empty())
909 return;
910 //Z_scripterrlog("PutPixels reached line %d\n", 983);
911
912 int32_t* pos = &v[0];
913 int32_t sz = v.size();
914 int32_t numpoints = (sdci[2]/10000);
915 if(sz & 1) --sz; //even amount only
916 if(numpoints > sz/2) //cap to array
917 numpoints = sz/2;
918 if(numpoints < 1)
919 return; //Don't draw 0 or negative point count
920
921 //Fix the draw Y offset. -Z 20th June, 2019
922 for ( int32_t q = 1; q < sz; q+=2 )
923 {
924 pos[q] += yoffset;
925 }
926 if(op <= 127) //translucent
927 {
928 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
929 }
930 else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
931
932 polygon(refbmp, numpoints, (int32_t*)pos, col);
933 //polygon(refbmp, (sdci[2]/10000), &v, col);
934 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
935 }
936
937 void do_spliner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
938 {
939 /* layer, x1, y1, x2, y2, x3, y3, x4, y4, color, opacity */
940
941 int32_t points[8] = { xoffset + (sdci[2]/10000), yoffset + (sdci[3]/10000),
942 xoffset + (sdci[4]/10000), yoffset + (sdci[5]/10000),
943 xoffset + (sdci[6]/10000), yoffset + (sdci[7]/10000),
944 xoffset + (sdci[8]/10000), yoffset + (sdci[9]/10000)
945 };
946
947 if(sdci[11]/10000 < 128) //translucent
948 {
949 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
950 }
951
952 spline(bmp, points, sdci[10]/10000);
953
954 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
955 }
956
957
958 404879 void do_putpixelr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
959 {
960 //sdci[1]=layer
961 //sdci[2]=x
962 //sdci[3]=y
963 //sdci[4]=color
964 //sdci[5]=rotation anchor x
965 //sdci[6]=rotation anchor y
966 //sdci[7]=rotation angle
967 //sdci[8]=opacity
968 404879 int32_t x1=sdci[2]/10000;
969 404879 int32_t y1=sdci[3]/10000;
970 404879 int32_t color=sdci[4]/10000;
971
972
2/2
✓ Branch 0 taken 404863 times.
✓ Branch 1 taken 16 times.
404879 if(sdci[8]/10000<=127) //translucent
973 {
974 16 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
975 16 }
976
977
1/2
✓ Branch 0 taken 404879 times.
✗ Branch 1 not taken.
404879 if(sdci[7]!=0) //rotation
978 {
979 int32_t xy[2];
980 int32_t rx=sdci[5]/10000;
981 int32_t ry=sdci[6]/10000;
982 fixed ra1=itofix(sdci[7]%10000)/10000;
983 fixed ra2=itofix(sdci[7]/10000);
984 fixed ra=ra1+ra2;
985
986 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
987 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
988 x1=xy[0];
989 y1=xy[1];
990 }
991
992 404879 putpixel(bmp, x1+xoffset, y1+yoffset, color);
993 404879 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
994 404879 }
995
996 void do_putpixelsr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
997 {
998 //Z_scripterrlog("Starting putpixels()%s\n");
999 //sdci[1]=layer
1000 //sdci[2]=array {x,y,colour,opacity}
1001 //sdci[3]=rotation anchor x
1002 //sdci[4]=rotation anchor y
1003 //sdci[5]=rotation angle
1004
1005
1006 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
1007
1008 if(!v_ptr)
1009 {
1010 al_trace("Screen->PutPixels: Vector pointer is null! Internal error. \n");
1011 return;
1012 }
1013
1014 std::vector<int32_t> &v = *v_ptr;
1015
1016 if(v.empty())
1017 return;
1018 //Z_scripterrlog("PutPixels reached line %d\n", 983);
1019
1020 int32_t* pos = &v[0];
1021 int32_t sz = v.size();
1022 //Z_scripterrlog("Vector size is: %d\n", sz);
1023 //for ( int32_t m = 0; m < 256; ++m ) Z_scripterrlog("Vector contents at pos[%d]: %d\n", m, pos[m]);
1024
1025 //FFCore.getValues(sdci[2]/10000, points, sz);
1026
1027
1028 int32_t x1 = 0;
1029 int32_t y1 = 0;
1030
1031 for ( int32_t q = 0; q < sz; q+=4 )
1032 {
1033 //Z_scripterrlog("Vector q: %d\n", q);
1034 //if ( q > sz-1 ) break;
1035 x1 = v.at(q); //pos[q];
1036 y1 = v.at(q+1); //pos[q+1];
1037 //Z_scripterrlog("x1 is: %d\n", x1);
1038 //Z_scripterrlog("y1 is: %d\n", 1);
1039 if(sdci[5]!=0) //rotation
1040 {
1041 int32_t xy[2];
1042 int32_t rx=sdci[3]/10000;
1043 int32_t ry=sdci[4]/10000;
1044 fixed ra1=itofix(sdci[5]%10000)/10000;
1045 fixed ra2=itofix(sdci[5]/10000);
1046 fixed ra=ra1+ra2;
1047
1048 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
1049 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
1050 x1=xy[0];
1051 y1=xy[1];
1052 }
1053 //Z_scripterrlog("PutPixels()%s value is %d\n","x",x1);
1054 //Z_scripterrlog("PutPixels()%s value is %d\n","y",y1);
1055 //Z_scripterrlog("PutPixels()%s value is %d\n","colour",points[q+2]);
1056 if ( v.at(q+3) /*pos[q+3]*/ < 128 ) drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
1057 else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
1058 putpixel(bmp, x1+xoffset, y1+yoffset, v.at(q+2) /*pos[q+2]*/);
1059 //if ( points[q+3] < 128 )
1060
1061 //else drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
1062 }
1063 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
1064 }
1065
1066 866805 void do_drawtiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1067 {
1068 //sdci[1]=layer
1069 //sdci[2]=x
1070 //sdci[3]=y
1071 //sdci[4]=tile
1072 //sdci[5]=tile width
1073 //sdci[6]=tile height
1074 //sdci[7]=color (cset)
1075 //sdci[8]=scale x
1076 //sdci[9]=scale y
1077 //sdci[10]=rotation anchor x
1078 //sdci[11]=rotation anchor y
1079 //sdci[12]=rotation angle
1080 //sdci[13]=flip
1081 //sdci[14]=transparency
1082 //sdci[15]=opacity
1083
1084 866805 int32_t w = sdci[5]/10000;
1085 866805 int32_t h = sdci[6]/10000;
1086
1087
4/8
✓ Branch 0 taken 866805 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 866805 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 866805 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 866805 times.
866805 if(w < 1 || h < 1 || h > 20 || w > 20)
1088 {
1089 return;
1090 }
1091
1092 866805 int32_t xscale=sdci[8]/10000;
1093 866805 int32_t yscale=sdci[9]/10000;
1094 866805 int32_t rx = sdci[10]/10000;
1095 866805 int32_t ry = sdci[11]/10000;
1096 866805 float rotation=sdci[12]/10000;
1097 866805 int32_t flip=(sdci[13]/10000)&3;
1098 866805 bool transparency=sdci[14]!=0;
1099 866805 int32_t opacity=sdci[15]/10000;
1100 866805 int32_t color=sdci[7]/10000;
1101
1102 866805 int32_t x1=sdci[2]/10000;
1103 866805 int32_t y1=sdci[3]/10000;
1104
1105 //don't scale if it's not safe to do so
1106 866805 bool canscale = true;
1107
1108
3/4
✓ Branch 0 taken 865766 times.
✓ Branch 1 taken 1039 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 865766 times.
866805 if(xscale==0||yscale==0)
1109 {
1110 1039 return;
1111 }
1112
1113
3/4
✓ Branch 0 taken 71231 times.
✓ Branch 1 taken 794535 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 71231 times.
865766 if(xscale<=0||yscale<=0)
1114 794535 canscale = false; //default size
1115
1116
4/4
✓ Branch 0 taken 71231 times.
✓ Branch 1 taken 794535 times.
✓ Branch 2 taken 101026 times.
✓ Branch 3 taken 693509 times.
865766 if((xscale>0 && yscale>0) || rotation) //scaled or rotated
1117 {
1118 172257 BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16);
1119
1120
1/2
✓ Branch 0 taken 172257 times.
✗ Branch 1 not taken.
172257 if(transparency) //transparency
1121 {
1122 172257 TileHelper::OverTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip);
1123 172257 }
1124 else //no transparency
1125 {
1126 TileHelper::OldPutTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip);
1127 }
1128
1129
2/2
✓ Branch 0 taken 104714 times.
✓ Branch 1 taken 67543 times.
172257 if(rotation != 0)
1130 {
1131 //low negative values indicate no anchor-point rotation
1132
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 104714 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
104714 if(rx>-777||ry>-777)
1133 {
1134 int32_t xy[2];
1135 104714 fixed ra1=itofix(sdci[12]%10000)/10000;
1136 104714 fixed ra2=itofix(sdci[12]/10000);
1137 104714 fixed ra=ra1+ra2;
1138 104714 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
1139 104714 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
1140 104714 x1=xy[0];
1141 104714 y1=xy[1];
1142 104714 }
1143
1144
2/2
✓ Branch 0 taken 3688 times.
✓ Branch 1 taken 101026 times.
104714 if(canscale) //scale first
1145 {
1146 //damnit all, .. fixme.
1147
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3688 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3688 times.
3688 BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
1148 3688 clear_bitmap(tempbit);
1149
1150 3688 stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
1151
1152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3688 times.
3688 if(opacity < 128)
1153 {
1154 clear_bitmap(prim_bmp);
1155 rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
1156 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1157 }
1158 else
1159 {
1160 3688 rotate_sprite(bmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
1161 }
1162
1163 3688 destroy_bitmap(tempbit);
1164 3688 }
1165 else //no scale
1166 {
1167
2/2
✓ Branch 0 taken 3586 times.
✓ Branch 1 taken 97440 times.
101026 if(opacity < 128)
1168 {
1169 3586 clear_bitmap(prim_bmp);
1170 3586 rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
1171 3586 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1172 3586 }
1173 else
1174 {
1175 97440 rotate_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
1176 }
1177 }
1178 104714 }
1179 else //scale only
1180 {
1181
1/2
✓ Branch 0 taken 67543 times.
✗ Branch 1 not taken.
67543 if(canscale)
1182 {
1183
2/2
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 64711 times.
67543 if(opacity<128)
1184 {
1185 2832 clear_bitmap(prim_bmp);
1186 2832 stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
1187 2832 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1188 2832 }
1189 else
1190 {
1191 64711 stretch_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
1192 }
1193 67543 }
1194 else //error -do not scale
1195 {
1196 if(opacity<128)
1197 {
1198 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1199 }
1200 else
1201 {
1202 draw_sprite(bmp, pbitty, x1+xoffset, y1+yoffset);
1203 }
1204 }
1205 }
1206
1207 172257 script_drawing_commands.ReleaseSubBitmap(pbitty);
1208
1209 172257 }
1210 else // no scale or rotation
1211 {
1212
1/2
✓ Branch 0 taken 693509 times.
✗ Branch 1 not taken.
693509 if(transparency)
1213 {
1214
2/2
✓ Branch 0 taken 7535 times.
✓ Branch 1 taken 685974 times.
693509 if(opacity<=127)
1215 7535 TileHelper::OverTileTranslucent(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity);
1216 else
1217 685974 TileHelper::OverTile(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip);
1218 693509 }
1219 else
1220 {
1221 if(opacity<=127)
1222 TileHelper::PutTileTranslucent(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity);
1223 else
1224 TileHelper::OldPutTile(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip);
1225 }
1226 }
1227 866805 }
1228
1229 void do_drawtilecloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1230 {
1231 //sdci[1]=layer
1232 //sdci[2]=x
1233 //sdci[3]=y
1234 //sdci[4]=tile
1235 //sdci[5]=tile width
1236 //sdci[6]=tile height
1237 //sdci[7]=flip
1238
1239 int32_t w = sdci[5]/10000;
1240 int32_t h = sdci[6]/10000;
1241
1242 if(w < 1 || h < 1 || h > 20 || w > 20)
1243 {
1244 return;
1245 }
1246
1247 int32_t flip=(sdci[7]/10000)&3;
1248
1249 int32_t x1=sdci[2]/10000;
1250 int32_t y1=sdci[3]/10000;
1251
1252 TileHelper::OverTileCloaked(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, flip);
1253 }
1254
1255
1256 1742823 void do_drawcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1257 {
1258 //sdci[1]=layer
1259 //sdci[2]=x
1260 //sdci[3]=y
1261 //sdci[4]=combo
1262 //sdci[5]=tile width
1263 //sdci[6]=tile height
1264 //sdci[7]=color (cset)
1265 //sdci[8]=scale x
1266 //sdci[9]=scale y
1267 //sdci[10]=rotation anchor x
1268 //sdci[11]=rotation anchor y
1269 //sdci[12]=rotation angle
1270 //sdci[13]=frame
1271 //sdci[14]=flip
1272 //sdci[15]=transparency
1273 //sdci[16]=opacity
1274
1275 1742823 int32_t w = sdci[5]/10000;
1276 1742823 int32_t h = sdci[6]/10000;
1277
1278
4/8
✓ Branch 0 taken 1742823 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1742823 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1742823 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1742823 times.
1742823 if(w<1||h<1||h>20||w>20)
1279 {
1280 return;
1281 }
1282 1742823 int32_t cmb = (sdci[4]/10000);
1283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1742823 times.
1742823 if((unsigned)cmb >= MAXCOMBOS)
1284 {
1285 Z_scripterrlog("DrawCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb);
1286 return;
1287 }
1288
1289 1742823 int32_t xscale=sdci[8]/10000;
1290 1742823 int32_t yscale=sdci[9]/10000;
1291 1742823 int32_t rx = sdci[10]/10000; //these work now
1292 1742823 int32_t ry = sdci[11]/10000; //these work now
1293 1742823 float rotation=sdci[12]/10000;
1294
1295 1742823 bool transparency=sdci[15]!=0;
1296 1742823 int32_t opacity=sdci[16]/10000;
1297 1742823 int32_t color=sdci[7]/10000;
1298 1742823 int32_t x1=sdci[2]/10000;
1299 1742823 int32_t y1=sdci[3]/10000;
1300
1301 1742823 const newcombo & c = combobuf[cmb];
1302 1742823 int32_t tiletodraw = combo_tile(c, x1, y1);
1303 1742823 int32_t flip = ((sdci[14]/10000) & 3) ^ c.flip;
1304 1742823 int32_t skiprows=c.skipanimy;
1305
1306
1307 //don't scale if it's not safe to do so
1308 1742823 bool canscale = true;
1309
1310
3/4
✓ Branch 0 taken 1742775 times.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1742775 times.
1742823 if(xscale==0||yscale==0)
1311 {
1312 48 return;
1313 }
1314
1315
3/4
✓ Branch 0 taken 22391 times.
✓ Branch 1 taken 1720384 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22391 times.
1742775 if(xscale<=0||yscale<=0)
1316 1720384 canscale = false; //default size
1317
1318
4/4
✓ Branch 0 taken 22391 times.
✓ Branch 1 taken 1720384 times.
✓ Branch 2 taken 97601 times.
✓ Branch 3 taken 1622783 times.
1742775 if((xscale>0 && yscale>0) || rotation) //scaled or rotated
1319 {
1320 119992 BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16); //-pbitty in the hisouse. :D
1321
1322
1/2
✓ Branch 0 taken 119992 times.
✗ Branch 1 not taken.
119992 if(transparency)
1323 {
1324 119992 TileHelper::OverTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
1325 119992 }
1326 else //no transparency
1327 {
1328 TileHelper::OldPutTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
1329 }
1330
1331
2/2
✓ Branch 0 taken 97710 times.
✓ Branch 1 taken 22282 times.
119992 if(rotation != 0) // rotate
1332 {
1333 //fixed point sucks ;0
1334
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97710 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
97710 if(rx>-777||ry>-777) //set the rotation anchor and rotate around that
1335 {
1336 int32_t xy[2];
1337 97710 fixed ra1=itofix(sdci[12]%10000)/10000;
1338 97710 fixed ra2=itofix(sdci[12]/10000);
1339 97710 fixed ra=ra1+ra2;
1340 97710 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
1341 97710 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
1342 97710 x1=xy[0];
1343 97710 y1=xy[1];
1344 97710 }
1345
1346
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 97601 times.
97710 if(canscale) //scale first
1347 {
1348
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 109 times.
109 BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
1349 109 clear_bitmap(tempbit);
1350
1351 109 stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
1352
1353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(opacity < 128)
1354 {
1355 clear_bitmap(prim_bmp);
1356 rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
1357 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1358 }
1359 else
1360 {
1361 109 rotate_sprite(bmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
1362 }
1363
1364 109 destroy_bitmap(tempbit);
1365 109 }
1366 else //no scale
1367 {
1368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97601 times.
97601 if(opacity < 128)
1369 {
1370 clear_bitmap(prim_bmp);
1371 rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
1372 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1373 }
1374 else
1375 {
1376 97601 rotate_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
1377 }
1378 }
1379 97710 }
1380 else //scale only
1381 {
1382
1/2
✓ Branch 0 taken 22282 times.
✗ Branch 1 not taken.
22282 if(canscale)
1383 {
1384
2/2
✓ Branch 0 taken 9291 times.
✓ Branch 1 taken 12991 times.
22282 if(opacity<128)
1385 {
1386 9291 clear_bitmap(prim_bmp);
1387 9291 stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
1388 9291 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1389 9291 }
1390 else
1391 {
1392 12991 stretch_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
1393 }
1394 22282 }
1395 else //error -do not scale
1396 {
1397 if(opacity<128)
1398 {
1399 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1400 }
1401 else
1402 {
1403 draw_sprite(bmp, pbitty, x1+xoffset, y1+yoffset);
1404 }
1405 }
1406 }
1407
1408 119992 script_drawing_commands.ReleaseSubBitmap(pbitty); //rap sucks
1409 119992 }
1410 else // no scale or rotation
1411 {
1412
1/2
✓ Branch 0 taken 1622783 times.
✗ Branch 1 not taken.
1622783 if(transparency)
1413 {
1414
2/2
✓ Branch 0 taken 41109 times.
✓ Branch 1 taken 1581674 times.
1622783 if(opacity<=127)
1415 41109 TileHelper::OverTileTranslucent(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
1416 else
1417 1581674 TileHelper::OverTile(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
1418 1622783 }
1419 else
1420 {
1421 if(opacity<=127)
1422 TileHelper::PutTileTranslucent(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
1423 else
1424 TileHelper::OldPutTile(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
1425 }
1426 }
1427 1742823 }
1428
1429 void do_drawcombocloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1430 {
1431 //sdci[1]=layer
1432 //sdci[2]=x
1433 //sdci[3]=y
1434 //sdci[4]=combo
1435 //sdci[5]=tile width
1436 //sdci[6]=tile height
1437 //sdci[7]=flip
1438
1439 int32_t w = sdci[5]/10000;
1440 int32_t h = sdci[6]/10000;
1441
1442 if(w<1||h<1||h>20||w>20)
1443 {
1444 return;
1445 }
1446 int32_t cmb = (sdci[4]/10000);
1447 if((unsigned)cmb >= MAXCOMBOS)
1448 {
1449 Z_scripterrlog("DrawComboCloaked() cannot draw combo '%d', as it is out of bounds.\n", cmb);
1450 return;
1451 }
1452
1453 int32_t x1=sdci[2]/10000;
1454 int32_t y1=sdci[3]/10000;
1455
1456 const newcombo & c = combobuf[cmb];
1457 int32_t tiletodraw = combo_tile(c, x1, y1);
1458 int32_t flip = ((sdci[7]/10000) & 3) ^ c.flip;
1459 int32_t skiprows=c.skipanimy;
1460
1461 TileHelper::OverTileCloaked(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, flip, skiprows);
1462 }
1463
1464
1465 4910510 void do_fasttiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1466 {
1467 /* layer, x, y, tile, color opacity */
1468
1469 4910510 int32_t opacity = sdci[6]/10000;
1470
1471
2/2
✓ Branch 0 taken 143401 times.
✓ Branch 1 taken 4767109 times.
4910510 if(opacity < 128)
1472 143401 overtiletranslucent16(bmp, sdci[4]/10000, xoffset+(sdci[2]/10000), yoffset+(sdci[3]/10000), sdci[5]/10000, 0, opacity);
1473 else
1474 4767109 overtile16(bmp, sdci[4]/10000, xoffset+(sdci[2]/10000), yoffset+(sdci[3]/10000), sdci[5]/10000, 0);
1475 4910510 }
1476
1477 void do_fasttilesr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1478 {
1479 /* layer, x, y, tile, color opacity */
1480
1481 //sdci[1]=layer
1482 //sdci[2]=array {x,y,tile,colour,opacity}
1483
1484 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
1485
1486 if(!v_ptr)
1487 {
1488 al_trace("Screen->PutPixels: Vector pointer is null! Internal error. \n");
1489 return;
1490 }
1491
1492 std::vector<int32_t> &v = *v_ptr;
1493
1494 if(v.empty())
1495 return;
1496 //Z_scripterrlog("PutPixels reached line %d\n", 983);
1497
1498 int32_t* pos = &v[0];
1499 int32_t sz = v.size();
1500
1501 for ( int32_t q = 0; q < sz; q+=5 )
1502 {
1503
1504 if(v.at(q+4) < 128)
1505 overtiletranslucent16(bmp, v.at(q), xoffset+(v.at(q+1)), yoffset+(v.at(q+2)), v.at(q+3), 0, v.at(q+4));
1506 else
1507 overtile16(bmp, v.at(q), xoffset+(v.at(q+1)), yoffset+(v.at(q+2)), v.at(q+3), 0);
1508 }
1509 }
1510
1511
1512
1513 18675043 void do_fastcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1514 {
1515 /* layer, x, y, tile, color opacity */
1516
1517 18675043 int32_t opacity = sdci[6] / 10000;
1518 18675043 int32_t x1 = sdci[2] / 10000;
1519 18675043 int32_t y1 = sdci[3] / 10000;
1520
1521 18675043 int32_t cmb = (sdci[4]/10000);
1522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18675043 times.
18675043 if((unsigned)cmb >= MAXCOMBOS)
1523 {
1524 Z_scripterrlog("FastCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb);
1525 return;
1526 }
1527 //if( index >= MAXCOMBOS ) return; //bleh.
1528 /*
1529 const newcombo & c = combobuf[index];
1530
1531 if(opacity < 128)
1532 overtiletranslucent16(bmp, combo_tile(c, x1, y1), xoffset+x1, yoffset+y1, sdci[5]/10000, (int32_t)c.flip, opacity);
1533 else
1534 overtile16(bmp, combo_tile(c, x1, y1), xoffset+x1, yoffset+y1, sdci[5]/10000, (int32_t)c.flip);
1535 */
1536
1537
2/2
✓ Branch 0 taken 171158 times.
✓ Branch 1 taken 18503885 times.
18675043 if(opacity < 128)
1538 {
1539 //void overcomboblocktranslucent(BITMAP *dest, int32_t x, int32_t y, int32_t cmbdat, int32_t cset, int32_t w, int32_t h, int32_t opacity)
1540 171158 overcomboblocktranslucent(bmp, xoffset+x1, yoffset+y1, cmb, sdci[5]/10000, 1, 1, 128);
1541
1542 171158 }
1543 else
1544 {
1545 //overcomboblock(BITMAP *dest, int32_t x, int32_t y, int32_t cmbdat, int32_t cset, int32_t w, int32_t h)
1546 18503885 overcomboblock(bmp, xoffset+x1, yoffset+y1, cmb, sdci[5]/10000, 1, 1);
1547 }
1548 18675043 }
1549
1550 void do_fastcombosr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1551 {
1552 /* layer, x, y, combo, cset, opacity */
1553
1554 //sdci[1]=layer
1555 //sdci[2]=array {x,y,combo,cset,opacity}
1556
1557 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
1558
1559 if(!v_ptr)
1560 {
1561 al_trace("Screen->FastCombos: Vector pointer is null! Internal error. \n");
1562 return;
1563 }
1564
1565 std::vector<int32_t> &v = *v_ptr;
1566
1567 if(v.empty())
1568 return;
1569
1570 int32_t* pos = &v[0];
1571 int32_t sz = v.size();
1572
1573 for ( int32_t q = 0; q < sz; q+=5 )
1574 {
1575 if((unsigned)(v.at(q+2)) >= MAXCOMBOS)
1576 {
1577 Z_scripterrlog("FastCombos() cannot draw combo '%d', as it is out of bounds.\n", v.at(q+2));
1578 continue;
1579 }
1580 if(v.at(q+4) < 128)
1581 {
1582 //void overcomboblocktranslucent(BITMAP *dest, int32_t x, int32_t y, int32_t cmbdat, int32_t cset, int32_t w, int32_t h, int32_t opacity)
1583 overcomboblocktranslucent(bmp, xoffset+v.at(q), yoffset+v.at(q+1), v.at(q+2), v.at(q+3), 1, 1, 128);
1584
1585 }
1586 else
1587 {
1588 //overcomboblock(BITMAP *dest, int32_t x, int32_t y, int32_t cmbdat, int32_t cset, int32_t w, int32_t h)
1589 overcomboblock(bmp, xoffset+v.at(q), yoffset+v.at(q+1), v.at(q+2), v.at(q+3), 1, 1);
1590 }
1591 }
1592 }
1593
1594
1595
1596
1597 936091 void do_drawcharr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1598 {
1599 //broken 2.50.2 and earlier drawcharacter()
1600
2/2
✓ Branch 0 taken 11595 times.
✓ Branch 1 taken 924496 times.
936091 if ( get_qr(qr_BROKENCHARINTDRAWING) )
1601 {
1602 //sdci[1]=layer
1603 //sdci[2]=x
1604 //sdci[3]=y
1605 //sdci[4]=font
1606 //sdci[5]=color
1607 //sdci[6]=bg color
1608 //sdci[7]=strech x (width)
1609 //sdci[8]=stretch y (height)
1610 //sdci[9]=char
1611 //sdci[10]=opacity
1612
1613 11595 int32_t x=sdci[2]/10000;
1614 11595 int32_t y=sdci[3]/10000;
1615 11595 int32_t font_index=sdci[4]/10000;
1616 11595 int32_t color=sdci[5]/10000;
1617 11595 int32_t bg_color=sdci[6]/10000; //-1 = transparent
1618 11595 int32_t w=sdci[7]/10000;
1619 11595 int32_t h=sdci[8]/10000;
1620 11595 char glyph=char(sdci[9]/10000);
1621 11595 int32_t opacity=sdci[10]/10000;
1622
1623 //safe check
1624
1/2
✓ Branch 0 taken 11595 times.
✗ Branch 1 not taken.
11595 if(bg_color < -1) bg_color = -1;
1625
1626
1/2
✓ Branch 0 taken 11595 times.
✗ Branch 1 not taken.
11595 if(w>512) w=512; //w=vbound(w,0,512);
1627
1628
1/2
✓ Branch 0 taken 11595 times.
✗ Branch 1 not taken.
11595 if(h>512) h=512; //h=vbound(h,0,512);
1629
1630 //undone
1631
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11595 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11595 if(w>0&&h>0)//stretch the character
1632 {
1633 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
1634
1635 if(opacity < 128)
1636 {
1637 if(w>128||h>128)
1638 {
1639 clear_bitmap(prim_bmp);
1640
1641 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1642 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
1643 draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset);
1644 }
1645 else //this is faster
1646 {
1647 BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h);
1648
1649 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1650 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
1651 draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset);
1652
1653 script_drawing_commands.ReleaseSubBitmap(pbmp2);
1654 }
1655 }
1656 else // no opacity
1657 {
1658 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1659 stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h);
1660 }
1661
1662 }
1663 else //no stretch
1664 {
1665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11595 times.
11595 if(opacity < 128)
1666 {
1667 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
1668 clear_bitmap(pbmp);
1669
1670 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1671 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
1672
1673 destroy_bitmap(pbmp);
1674 }
1675 else // no opacity
1676 {
1677 11595 textprintf_ex(bmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph);
1678 }
1679 }
1680 11595 }
1681
1682 else //2.53.0 fixed version and later.
1683 {
1684
1685 //sdci[1]=layer
1686 //sdci[2]=x
1687 //sdci[3]=y
1688 //sdci[4]=font
1689 //sdci[5]=color
1690 //sdci[6]=bg color
1691 //sdci[7]=strech x (width)
1692 //sdci[8]=stretch y (height)
1693 //sdci[9]=char
1694 //sdci[10]=opacity
1695
1696 924496 int32_t x=sdci[2]/10000;
1697 924496 int32_t y=sdci[3]/10000;
1698 924496 int32_t font_index=sdci[4]/10000;
1699 924496 int32_t color=sdci[5]/10000;
1700 924496 int32_t bg_color=sdci[6]/10000; //-1 = transparent
1701 924496 int32_t w=sdci[7]/10000;
1702 924496 int32_t h=sdci[8]/10000;
1703 924496 char glyph=char(sdci[9]/10000);
1704 924496 int32_t opacity=sdci[10]/10000;
1705
1706 //safe check
1707
1/2
✓ Branch 0 taken 924496 times.
✗ Branch 1 not taken.
924496 if(bg_color < -1) bg_color = -1;
1708
1709
1/2
✓ Branch 0 taken 924496 times.
✗ Branch 1 not taken.
924496 if(w>512) w=512; //w=vbound(w,0,512);
1710
1711
1/2
✓ Branch 0 taken 924496 times.
✗ Branch 1 not taken.
924496 if(h>512) h=512; //h=vbound(h,0,512);
1712
1713 //undone
1714
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 924496 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
924496 if(w>0&&h>0)//stretch the character
1715 {
1716 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
1717
1718 if(opacity < 128)
1719 {
1720 if(w>128||h>128)
1721 {
1722 clear_bitmap(prim_bmp);
1723
1724 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1725 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
1726 draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset);
1727 }
1728 else //this is faster
1729 {
1730 BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h);
1731
1732 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1733 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
1734 draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset);
1735
1736 script_drawing_commands.ReleaseSubBitmap(pbmp2);
1737 }
1738 }
1739 else // no opacity
1740 {
1741 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1742 stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h);
1743 }
1744
1745 }
1746 else //no stretch
1747 {
1748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 924496 times.
924496 if(opacity < 128)
1749 {
1750 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
1751 clear_bitmap(pbmp);
1752
1753 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1754 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
1755
1756 destroy_bitmap(pbmp);
1757 }
1758 else // no opacity
1759 {
1760 924496 textprintf_ex(bmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph);
1761 }
1762 }
1763
1764 }
1765
1766 936091 }
1767
1768
1769 97816 void do_drawintr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1770 {
1771 //broken 2.50.2 and earlier drawinteger()
1772
2/2
✓ Branch 0 taken 35718 times.
✓ Branch 1 taken 62098 times.
97816 if ( get_qr(qr_BROKENCHARINTDRAWING) )
1773 {
1774 //sdci[1]=layer
1775 //sdci[2]=x
1776 //sdci[3]=y
1777 //sdci[4]=font
1778 //sdci[5]=color
1779 //sdci[6]=bg color
1780 //sdci[7]=strech x (width)
1781 //sdci[8]=stretch y (height)
1782 //sdci[9]=integer
1783 //sdci[10]=num decimal places
1784 //sdci[11]=opacity
1785
1786 35718 int32_t x=sdci[2]/10000;
1787 35718 int32_t y=sdci[3]/10000;
1788 35718 int32_t font_index=sdci[4]/10000;
1789 35718 int32_t color=sdci[5]/10000;
1790 35718 int32_t bg_color=sdci[6]/10000; //-1 = transparent
1791 35718 int32_t w=sdci[7]/10000;
1792 35718 int32_t h=sdci[8]/10000;
1793 //float number=static_cast<float>(sdci[9])/10000.0f;
1794 35718 int32_t decplace=sdci[10]/10000;
1795 35718 int32_t opacity=sdci[11]/10000;
1796
1797 //safe check
1798
1/2
✓ Branch 0 taken 35718 times.
✗ Branch 1 not taken.
35718 if(bg_color < -1) bg_color = -1;
1799
1800
1/2
✓ Branch 0 taken 35718 times.
✗ Branch 1 not taken.
35718 if(w>512) w=512; //w=vbound(w,0,512);
1801
1802
1/2
✓ Branch 0 taken 35718 times.
✗ Branch 1 not taken.
35718 if(h>512) h=512; //h=vbound(h,0,512);
1803
1804 char numbuf[15];
1805
1806
1/6
✓ Branch 0 taken 35718 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35718 switch(decplace)
1807 {
1808 default:
1809 case 0:
1810 35718 sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was
1811 35718 break; //reducing the value by -1, so 8.000 printed as '7'. -Z
1812
1813 case 1:
1814 //sprintf(numbuf,"%.01f",number);
1815 sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower?
1816 break;
1817
1818 case 2:
1819 //sprintf(numbuf,"%.02f",number);
1820 sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f));
1821 break;
1822
1823 case 3:
1824 //sprintf(numbuf,"%.03f",number);
1825 sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f));
1826 break;
1827
1828 case 4:
1829 //sprintf(numbuf,"%.04f",number);
1830 sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f));
1831 break;
1832 }
1833
1834
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 35718 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
35718 if(w>0&&h>0)//stretch
1835 {
1836 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
1837
1838 if(opacity < 128)
1839 {
1840 if(w>128||h>128)
1841 {
1842 clear_bitmap(prim_bmp);
1843
1844 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1845 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
1846 draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset);
1847 }
1848 else
1849 {
1850 BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h);
1851 clear_bitmap(pbmp2);
1852
1853 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1854 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
1855 draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset);
1856
1857 destroy_bitmap(pbmp2);
1858 }
1859 }
1860 else // no opacity
1861 {
1862 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1863 stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h);
1864 }
1865
1866 }
1867 else //no stretch
1868 {
1869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35718 times.
35718 if(opacity < 128)
1870 {
1871 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
1872 clear_bitmap(pbmp);
1873
1874 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1875 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
1876
1877 destroy_bitmap(pbmp);
1878 }
1879 else // no opacity
1880 {
1881 35718 textout_ex(bmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color);
1882 }
1883 }
1884
1885 35718 }
1886
1887 else //2.53.0 fixed version and later.
1888 {
1889 //sdci[1]=layer
1890 //sdci[2]=x
1891 //sdci[3]=y
1892 //sdci[4]=font
1893 //sdci[5]=color
1894 //sdci[6]=bg color
1895 //sdci[7]=strech x (width)
1896 //sdci[8]=stretch y (height)
1897 //sdci[9]=integer
1898 //sdci[10]=num decimal places
1899 //sdci[11]=opacity
1900
1901 62098 int32_t x=sdci[2]/10000;
1902 62098 int32_t y=sdci[3]/10000;
1903 62098 int32_t font_index=sdci[4]/10000;
1904 62098 int32_t color=sdci[5]/10000;
1905 62098 int32_t bg_color=sdci[6]/10000; //-1 = transparent
1906 62098 int32_t w=sdci[7]/10000;
1907 62098 int32_t h=sdci[8]/10000;
1908 //float number=static_cast<float>(sdci[9])/10000.0f;
1909 //int32_t numberint = sdci[9]/10000;
1910 62098 int32_t decplace=sdci[10]/10000;
1911 62098 int32_t opacity=sdci[11]/10000;
1912
1913 //safe check
1914
1/2
✓ Branch 0 taken 62098 times.
✗ Branch 1 not taken.
62098 if(bg_color < -1) bg_color = -1;
1915
1916
1/2
✓ Branch 0 taken 62098 times.
✗ Branch 1 not taken.
62098 if(w>512) w=512; //w=vbound(w,0,512);
1917
1918
1/2
✓ Branch 0 taken 62098 times.
✗ Branch 1 not taken.
62098 if(h>512) h=512; //h=vbound(h,0,512);
1919
1920 char numbuf[15];
1921
1922
1/6
✓ Branch 0 taken 62098 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62098 switch(decplace)
1923 {
1924 default:
1925 case 0:
1926 62098 sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was
1927 62098 break; //reducing the value by -1, so 8.000 printed as '7'. -Z
1928
1929 case 1:
1930 //sprintf(numbuf,"%.01f",number);
1931 sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower?
1932 break;
1933
1934 case 2:
1935 //sprintf(numbuf,"%.02f",number);
1936 sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f));
1937 break;
1938
1939 case 3:
1940 //sprintf(numbuf,"%.03f",number);
1941 sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f));
1942 break;
1943
1944 case 4:
1945 //sprintf(numbuf,"%.04f",number);
1946 sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f));
1947 break;
1948 }
1949
1950 //FONT* font=get_zc_font(sdci[4]/10000);
1951
1952
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62098 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62098 if(w>0&&h>0)//stretch
1953 {
1954 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(get_zc_font(font_index), numbuf)+1, text_height(get_zc_font(font_index)));
1955 clear_bitmap(pbmp);
1956 //script_drawing_commands.GetSmallTextureBitmap(1,1);
1957
1958 if(opacity < 128)
1959 {
1960 if(w>128||h>128)
1961 {
1962 clear_bitmap(prim_bmp);
1963
1964 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1965 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
1966 draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset);
1967 }
1968 else
1969 {
1970 BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h);
1971 clear_bitmap(pbmp2);
1972
1973 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1974 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
1975 draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset);
1976
1977 destroy_bitmap(pbmp2);
1978 }
1979 }
1980 else // no opacity
1981 {
1982 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1983 stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h);
1984 }
1985
1986 }
1987 else //no stretch
1988 {
1989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62098 times.
62098 if(opacity < 128)
1990 {
1991 FONT* font = get_zc_font(font_index);
1992 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(font, numbuf), text_height(font));
1993 clear_bitmap(pbmp);
1994
1995 textout_ex(pbmp, font, numbuf, 0, 0, color, bg_color);
1996 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
1997
1998 destroy_bitmap(pbmp);
1999 }
2000 else // no opacity
2001 {
2002 62098 textout_ex(bmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color);
2003 }
2004 }
2005 }
2006 97816 }
2007
2008
2009 1263883 void do_drawstringr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2010 {
2011 //sdci[1]=layer
2012 //sdci[2]=x
2013 //sdci[3]=y
2014 //sdci[4]=font
2015 //sdci[5]=color
2016 //sdci[6]=bg color
2017 //sdci[7]=format_option
2018 //sdci[8]=string
2019 //sdci[9]=opacity
2020
2021 1263883 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
2022
2023
1/2
✓ Branch 0 taken 1263883 times.
✗ Branch 1 not taken.
1263883 if(!str)
2024 {
2025 al_trace("String pointer is null! Internal error. \n");
2026 return;
2027 }
2028
2029 1263883 int32_t x=sdci[2]/10000;
2030 1263883 int32_t y=sdci[3]/10000;
2031 1263883 FONT* font=get_zc_font(sdci[4]/10000);
2032 1263883 int32_t color=sdci[5]/10000;
2033 1263883 int32_t bg_color=sdci[6]/10000; //-1 = transparent
2034 1263883 int32_t format_type=sdci[7]/10000;
2035 1263883 int32_t opacity=sdci[9]/10000;
2036 //sdci[8] not needed :)
2037
2038 //safe check
2039
1/2
✓ Branch 0 taken 1263883 times.
✗ Branch 1 not taken.
1263883 if(bg_color < -1) bg_color = -1;
2040
2041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1263883 times.
1263883 if(opacity < 128)
2042 {
2043 int32_t width=zc_min(text_length(font, str->c_str()), 512);
2044 if (width < 1) return; //SANITY -Em
2045 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font));
2046 clear_bitmap(pbmp);
2047 textout_ex(pbmp, font, str->c_str(), 0, 0, color, bg_color);
2048 if(format_type == 2) // right-sided text
2049 x-=width;
2050 else if(format_type == 1) // centered text
2051 x-=width/2;
2052 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
2053 destroy_bitmap(pbmp);
2054 }
2055 else // no opacity
2056 {
2057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1263883 times.
1263883 if(format_type == 2) // right-sided text
2058 {
2059 textout_right_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
2060 }
2061
2/2
✓ Branch 0 taken 524326 times.
✓ Branch 1 taken 739557 times.
1263883 else if(format_type == 1) // centered text
2062 {
2063 524326 textout_centre_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
2064 524326 }
2065 else // standard left-sided text
2066 {
2067 739557 textout_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
2068 }
2069 }
2070 1263883 }
2071
2072 153213 void do_drawstringr2(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2073 {
2074 //sdci[1]=layer
2075 //sdci[2]=x
2076 //sdci[3]=y
2077 //sdci[4]=font
2078 //sdci[5]=color
2079 //sdci[6]=bg color
2080 //sdci[7]=format_option
2081 //sdci[8]=string
2082 //sdci[9]=opacity
2083 //sdci[10]=shadowtype
2084 //sdci[11]=shadow_color
2085
2086 153213 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
2087
2088
1/2
✓ Branch 0 taken 153213 times.
✗ Branch 1 not taken.
153213 if(!str)
2089 {
2090 al_trace("String pointer is null! Internal error. \n");
2091 return;
2092 }
2093
2094 153213 int32_t x=sdci[2]/10000;
2095 153213 int32_t y=sdci[3]/10000;
2096 153213 FONT* font=get_zc_font(sdci[4]/10000);
2097 153213 int32_t color=sdci[5]/10000;
2098 153213 int32_t bg_color=sdci[6]/10000; //-1 = transparent
2099 153213 int32_t format_type=sdci[7]/10000;
2100 153213 int32_t opacity=sdci[9]/10000;
2101 153213 int32_t textstyle = sdci[10]/10000;
2102 153213 int32_t shadow_color = sdci[11]/10000;
2103 //sdci[8] not needed :)
2104
2105 //safe check
2106
1/2
✓ Branch 0 taken 153213 times.
✗ Branch 1 not taken.
153213 if(bg_color < -1) bg_color = -1;
2107
2108
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 152473 times.
153213 if(opacity < 128)
2109 {
2110
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 int32_t width=zc_min(text_length(font, str->c_str()), 512);
2111
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if (width < 1) return; //SANITY -Em
2112 740 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font));
2113 740 clear_bitmap(pbmp);
2114 740 textout_styled_aligned_ex(pbmp, font, str->c_str(), 0, 0, textstyle, sstaLEFT, color, shadow_color, bg_color);
2115 740 textout_ex(pbmp, font, str->c_str(), 0, 0, color, bg_color);
2116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 740 times.
740 if(format_type == 2) // right-sided text
2117 x-=width;
2118
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 else if(format_type == 1) // centered text
2119 740 x-=width/2;
2120 740 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
2121 740 destroy_bitmap(pbmp);
2122 740 }
2123 else // no opacity
2124 {
2125 152473 textout_styled_aligned_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, textstyle, format_type, color, shadow_color, bg_color);
2126 }
2127 153213 }
2128
2129
2130 9266 void do_drawquadr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2131 {
2132 //sdci[1]=layer
2133 //sdci[2]=x1
2134 //sdci[3]=y1
2135 //sdci[4]=x2
2136 //sdci[5]=y2
2137 //sdci[6]=x3
2138 //sdci[7]=y3
2139 //sdci[8]=x4
2140 //sdci[9]=y4
2141 //sdci[10]=width
2142 //sdci[11]=height
2143 //sdci[12]=cset
2144 //sdci[13]=flip
2145 //sdci[14]=tile/combo
2146 //sdci[15]=polytype
2147
2148 9266 int32_t x1 = sdci[2]/10000;
2149 9266 int32_t y1 = sdci[3]/10000;
2150 9266 int32_t x2 = sdci[4]/10000;
2151 9266 int32_t y2 = sdci[5]/10000;
2152 9266 int32_t x3 = sdci[6]/10000;
2153 9266 int32_t y3 = sdci[7]/10000;
2154 9266 int32_t x4 = sdci[8]/10000;
2155 9266 int32_t y4 = sdci[9]/10000;
2156 9266 int32_t w = sdci[10]/10000;
2157 9266 int32_t h = sdci[11]/10000;
2158 9266 int32_t color = sdci[12]/10000;
2159 9266 int32_t flip=(sdci[13]/10000)&3;
2160 9266 int32_t tile = sdci[14]/10000;
2161 9266 int32_t polytype = sdci[15]/10000;
2162
2163 //todo: finish palette shading
2164 /*
2165 POLYTYPE_FLAT
2166 POLYTYPE_GCOL
2167 POLYTYPE_GRGB
2168 POLYTYPE_ATEX
2169 POLYTYPE_PTEX
2170 POLYTYPE_ATEX_MASK
2171 POLYTYPE_PTEX_MASK
2172 POLYTYPE_ATEX_LIT
2173 POLYTYPE_PTEX_LIT
2174 POLYTYPE_ATEX_MASK_LIT
2175 POLYTYPE_PTEX_MASK_LIT
2176 POLYTYPE_ATEX_TRANS
2177 POLYTYPE_PTEX_TRANS
2178 POLYTYPE_ATEX_MASK_TRANS
2179 POLYTYPE_PTEX_MASK_TRANS
2180 */
2181 9266 polytype = vbound(polytype, 0, 14);
2182
2183
2/4
✓ Branch 0 taken 9266 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9266 times.
9266 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
2184 {
2185 Z_message("Quad() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
2186 return; //non power of two error
2187 }
2188
2189 9266 int32_t tex_width = w*16;
2190 9266 int32_t tex_height = h*16;
2191
2192 BITMAP *tex;
2193
2194 9266 bool mustDestroyBmp = false;
2195
2196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9266 times.
9266 if ( tile > 65519 ) tex = zscriptDrawingRenderTarget->GetBitmapPtr(tile - 65519);
2197 9266 else tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
2198
2199
1/2
✓ Branch 0 taken 9266 times.
✗ Branch 1 not taken.
9266 if(!tex)
2200 {
2201 mustDestroyBmp = true;
2202 tex = create_bitmap_ex(8, tex_width, tex_height);
2203 clear_bitmap(tex);
2204 }
2205
2206 int32_t col[4];
2207 /*
2208 if( color < 0 )
2209 {
2210 col[0]=draw_container.color_buffer[0];
2211 col[1]=draw_container.color_buffer[1];
2212 col[2]=draw_container.color_buffer[2];
2213 col[3]=draw_container.color_buffer[3];
2214 }
2215 else */
2216 {
2217 9266 col[0]=col[1]=col[2]=col[3]=color;
2218 }
2219
2220
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9266 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9266 if(tile > 0 && tile <= 65519) // TILE
2221 {
2222 TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip);
2223 }
2224
2225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9266 times.
9266 if ( tile < 0 ) // COMBO
2226 {
2227 9266 const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ];
2228 9266 const int32_t tiletodraw = combo_tile(c, x1, y1);
2229 9266 flip = flip ^ c.flip;
2230
2231 9266 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip);
2232 9266 }
2233
2234 9266 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
2235 9266 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(tex_height), col[1] };
2236 9266 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(tex_width), static_cast<float>(tex_height), col[2] };
2237 9266 V3D_f V4 = { static_cast<float>(x4+xoffset), static_cast<float>(y4+yoffset), 0, static_cast<float>(tex_width), 0, col[3] };
2238
2239 9266 quad3d_f(bmp, polytype, tex, &V1, &V2, &V3, &V4);
2240
2241
1/2
✓ Branch 0 taken 9266 times.
✗ Branch 1 not taken.
9266 if(mustDestroyBmp)
2242 destroy_bitmap(tex);
2243
2244 9266 }
2245
2246
2247 void do_drawtriangler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2248 {
2249 //sdci[1]=layer
2250 //sdci[2]=x1
2251 //sdci[3]=y1
2252 //sdci[4]=x2
2253 //sdci[5]=y2
2254 //sdci[6]=x3
2255 //sdci[7]=y3
2256 //sdci[8]=width
2257 //sdci[9]=height
2258 //sdci[10]=cset
2259 //sdci[11]=flip
2260 //sdci[12]=tile/combo
2261 //sdci[13]=polytype
2262
2263 int32_t x1 = sdci[2]/10000;
2264 int32_t y1 = sdci[3]/10000;
2265 int32_t x2 = sdci[4]/10000;
2266 int32_t y2 = sdci[5]/10000;
2267 int32_t x3 = sdci[6]/10000;
2268 int32_t y3 = sdci[7]/10000;
2269 int32_t w = sdci[8]/10000;
2270 int32_t h = sdci[9]/10000;
2271 int32_t color = sdci[10]/10000;
2272 int32_t flip=(sdci[11]/10000)&3;
2273 int32_t tile = sdci[12]/10000;
2274 int32_t polytype = sdci[13]/10000;
2275
2276 polytype = vbound(polytype, 0, 14);
2277
2278 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
2279 {
2280 Z_message("Quad() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
2281 return; //non power of two error
2282 }
2283
2284 int32_t tex_width = w*16;
2285 int32_t tex_height = h*16;
2286
2287 bool mustDestroyBmp = false;
2288 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
2289
2290 if(!tex)
2291 {
2292 mustDestroyBmp = true;
2293 tex = create_bitmap_ex(8, tex_width, tex_height);
2294 clear_bitmap(tex);
2295 }
2296
2297 int32_t col[3];
2298 /*
2299 if( color < 0 )
2300 {
2301 col[0]=draw_container.color_buffer[0];
2302 col[1]=draw_container.color_buffer[1];
2303 col[2]=draw_container.color_buffer[2];
2304 }
2305 else */
2306 {
2307 col[0]=col[1]=col[2]=color;
2308 }
2309
2310 if(tile > 0) // TILE
2311 {
2312 TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip);
2313 }
2314 else // COMBO
2315 {
2316 const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ];
2317 const int32_t tiletodraw = combo_tile(c, x1, y1);
2318 flip = flip ^ c.flip;
2319
2320 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip);
2321 }
2322
2323 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
2324 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(tex_height), col[1] };
2325 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(tex_width), static_cast<float>(tex_height), col[2] };
2326
2327
2328 triangle3d_f(bmp, polytype, tex, &V1, &V2, &V3);
2329
2330 if(mustDestroyBmp)
2331 destroy_bitmap(tex);
2332 }
2333
2334
2335 834978 void do_drawbitmapr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2336 {
2337 //sdci[1]=layer
2338 //sdci[2]=bitmap
2339 //sdci[3]=sourcex
2340 //sdci[4]=sourcey
2341 //sdci[5]=sourcew
2342 //sdci[6]=sourceh
2343 //sdci[7]=destx
2344 //sdci[8]=desty
2345 //sdci[9]=destw
2346 //sdci[10]=desth
2347 //sdci[11]=rotation
2348 //sdci[12]=mask
2349
2350 834978 int32_t bitmapIndex = sdci[2]/10000;
2351 834978 int32_t sx = sdci[3]/10000;
2352 834978 int32_t sy = sdci[4]/10000;
2353 834978 int32_t sw = sdci[5]/10000;
2354 834978 int32_t sh = sdci[6]/10000;
2355 834978 int32_t dx = sdci[7]/10000;
2356 834978 int32_t dy = sdci[8]/10000;
2357 834978 int32_t dw = sdci[9]/10000;
2358 834978 int32_t dh = sdci[10]/10000;
2359 834978 float rot = sdci[11]/10000;
2360 834978 bool masked = (sdci[12] != 0);
2361
2362 //bugfix
2363 834978 sx = vbound(sx, 0, 512);
2364 834978 sy = vbound(sy, 0, 512);
2365 834978 sw = vbound(sw, 0, 512 - sx); //keep the w/h within range as well
2366 834978 sh = vbound(sh, 0, 512 - sy);
2367
2368
2369
2/4
✓ Branch 0 taken 834978 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 834978 times.
834978 if(sx >= ZScriptDrawingRenderTarget::BitmapWidth || sy >= ZScriptDrawingRenderTarget::BitmapHeight)
2370 return;
2371
2372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 834978 times.
834978 bool stretched = (sw != dw || sh != dh);
2373
2374 834978 BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
2375
2376
1/2
✓ Branch 0 taken 834978 times.
✗ Branch 1 not taken.
834978 if(!sourceBitmap)
2377 {
2378 Z_message("Warning: Screen->DrawBitmap(%d) contains invalid data or is not initialized.\n", bitmapIndex);
2379 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
2380 return;
2381 }
2382
2383 834978 BITMAP* subBmp = 0;
2384
2385
1/2
✓ Branch 0 taken 834978 times.
✗ Branch 1 not taken.
834978 if(rot != 0)
2386 {
2387 subBmp = script_drawing_commands.AquireSubBitmap(dw, dh);
2388
2389 if(!subBmp)
2390 {
2391 Z_scripterrlog("DrawBitmap() failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation");
2392 return;
2393 }
2394 }
2395
2396
2397 834978 dx = dx + xoffset;
2398 834978 dy = dy + yoffset;
2399
2400
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 834738 times.
834978 if(stretched)
2401 {
2402
1/2
✓ Branch 0 taken 240 times.
✗ Branch 1 not taken.
240 if(masked)
2403 {
2404
1/2
✓ Branch 0 taken 240 times.
✗ Branch 1 not taken.
240 if(rot != 0)
2405 {
2406 //if ( rot == 4096 ) { //translucent
2407 // masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2408 // //rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2409 // draw_trans_sprite(bmp, subBmp, dx, dy);
2410 // //draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, 0);
2411
2412
2413 // }
2414 //else {
2415 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2416 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2417 //rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2418 //
2419
2420 // }
2421 }
2422 else
2423 240 masked_stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
2424 240 }
2425 else
2426 {
2427 if(rot != 0)
2428 {
2429 //if ( rot == 4096 ) { //translucent
2430 // stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2431 // draw_trans_sprite(bmp, subBmp, dx, dy);
2432 // }
2433 //else {
2434 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2435 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2436 // }
2437 }
2438 else
2439 stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
2440 }
2441 240 }
2442 else
2443 {
2444
2/2
✓ Branch 0 taken 830016 times.
✓ Branch 1 taken 4722 times.
834738 if(masked)
2445 {
2446
1/2
✓ Branch 0 taken 830016 times.
✗ Branch 1 not taken.
830016 if(rot != 0)
2447 {
2448 //if ( rot == 4096 ) {//translucent
2449 // masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
2450 //rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2451
2452 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2453 //rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2454 // draw_trans_sprite(bmp, subBmp, dx, dy);
2455 // }
2456 //else {
2457 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
2458 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2459 // }
2460 }
2461 else
2462 830016 masked_blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
2463 830016 }
2464 else
2465 {
2466
1/2
✓ Branch 0 taken 4722 times.
✗ Branch 1 not taken.
4722 if(rot != 0)
2467 {
2468 //if ( rot == 4096 ) { //translucent
2469 // blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
2470 // draw_trans_sprite(bmp, subBmp, dx, dy);
2471 // }
2472 //else {
2473 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
2474 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2475 // }
2476 }
2477 else
2478 4722 blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
2479 }
2480 }
2481
2482 //cleanup
2483
1/2
✓ Branch 0 taken 834978 times.
✗ Branch 1 not taken.
834978 if(subBmp)
2484 {
2485 script_drawing_commands.ReleaseSubBitmap(subBmp);
2486 }
2487 834978 }
2488
2489
2490 //Draw]()
2491 void do_drawbitmapexr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2492 {
2493 /*
2494 //sdci[1]=layer
2495 //sdci[2]=bitmap
2496 //sdci[3]=sourcex
2497 //sdci[4]=sourcey
2498 //sdci[5]=sourcew
2499 //sdci[6]=sourceh
2500 //sdci[7]=destx
2501 //sdci[8]=desty
2502 //sdci[9]=destw
2503 //sdci[10]=desth
2504 //sdci[11]=rotation/angle
2505 //scdi[12] = pivot cx
2506 //sdci[13] = pivot cy
2507 //scdi[14] = effect flags
2508
2509
2510 const int32_t BITDX_NORMAL = 0;
2511 const int32_t BITDX_TRANS = 1; //Translucent
2512 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
2513 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
2514 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
2515 //Note: Some modes cannot be combined. if a combination is not supported, an error
2516 // detailing this will be shown in allegro.log.
2517
2518 //scdi[15] = litcolour
2519 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
2520 /not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2521
2522 //sdci[16]=mask
2523
2524 */
2525
2526 int32_t bitmapIndex = sdci[2]/10000;
2527 int32_t sx = sdci[3]/10000;
2528 int32_t sy = sdci[4]/10000;
2529 int32_t sw = sdci[5]/10000;
2530 int32_t sh = sdci[6]/10000;
2531 int32_t dx = sdci[7]/10000;
2532 int32_t dy = sdci[8]/10000;
2533 int32_t dw = sdci[9]/10000;
2534 int32_t dh = sdci[10]/10000;
2535 float rot = sdci[11]/10000;
2536 int32_t cx = sdci[12]/10000;
2537 int32_t cy = sdci[13]/10000;
2538 int32_t mode = sdci[14]/10000;
2539 int32_t litcolour = sdci[15]/10000;
2540 bool masked = (sdci[16] != 0);
2541
2542
2543
2544 //bugfix
2545 sx = vbound(sx, 0, 512);
2546 sy = vbound(sy, 0, 512);
2547 sw = vbound(sw, 0, 512 - sx); //keep the w/h within range as well
2548 sh = vbound(sh, 0, 512 - sy);
2549
2550
2551 if(sx >= ZScriptDrawingRenderTarget::BitmapWidth || sy >= ZScriptDrawingRenderTarget::BitmapHeight)
2552 return;
2553
2554 bool stretched = (sw != dw || sh != dh);
2555
2556 BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
2557
2558 if(!sourceBitmap)
2559 {
2560 Z_message("Warning: Screen->DrawBitmap(%d) contains invalid data or is not initialized.\n", bitmapIndex);
2561 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
2562 return;
2563 }
2564
2565 BITMAP* subBmp = 0;
2566
2567 /*
2568 if ( bitmapIndex == -1 ) {
2569 blit(bmp, sourceBitmap, sx, sy, 0, 0, dw, dh);
2570 }
2571 */
2572
2573 if(rot != 0 || mode != 0)
2574 {
2575 subBmp = script_drawing_commands.AquireSubBitmap(dw, dh);
2576
2577 if(!subBmp)
2578 {
2579 Z_scripterrlog("bitmap->Blit failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation");
2580 return;
2581 }
2582 }
2583
2584
2585 dx = dx + xoffset;
2586 dy = dy + yoffset;
2587
2588 if(stretched)
2589 {
2590 if(masked) //stretched and masked
2591 {
2592 if ( rot == 0 ) //if not rotated
2593 {
2594 switch(mode)
2595 {
2596 case 1:
2597 //transparent
2598 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2599 draw_trans_sprite(bmp, subBmp, dx, dy);
2600 break;
2601
2602
2603 case 2:
2604 //pivot?
2605 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2606 pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2607 //Pivoting requires two more args
2608 break;
2609
2610 case 3:
2611 //pivot + trans
2612 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2613 pivot_sprite_trans(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2614 break;
2615
2616 case 4:
2617 //flip v
2618 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2619 draw_sprite_v_flip(bmp, subBmp, dx, dy);
2620 break;
2621
2622 case 5:
2623 //trans + v flip
2624 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2625 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
2626 break;
2627
2628 case 6:
2629 //pivot + v flip
2630 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2631 pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2632 break;
2633
2634 case 8:
2635 //vlip h
2636 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2637 draw_sprite_h_flip(bmp, subBmp, dx, dy);
2638 break;
2639
2640 case 9:
2641 //trans + h flip
2642 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2643 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
2644 break;
2645
2646 case 10:
2647 //flip H and pivot
2648 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
2649 //return error cannot pivot and h flip
2650 break;
2651
2652 case 12:
2653 //vh flip
2654 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2655 draw_sprite_vh_flip(bmp, subBmp, dx, dy);
2656 break;
2657
2658 case 13:
2659 //trans + vh flip
2660 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2661 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
2662 break;
2663
2664 case 14:
2665 //pivot and vh flip
2666 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
2667 //return error cannot both pivot and vh flip
2668 break;
2669
2670 case 16:
2671 //lit
2672 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2673 draw_lit_sprite(bmp, subBmp, dx, dy, litcolour);
2674 break;
2675
2676 case 18:
2677 //pivot, lit
2678 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2679 pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
2680 break;
2681
2682 case 20:
2683 //lit + v flip
2684 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2685 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
2686 break;
2687
2688 case 22:
2689 //Pivot, vflip, lit
2690 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2691 pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
2692 break;
2693
2694 case 24:
2695 //lit + h flip
2696 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2697 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
2698 break;
2699
2700 case 26:
2701 //pivot + lit + hflip
2702 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
2703 //return error cannot pivot, lit, and flip
2704 break;
2705
2706 case 28:
2707 //lit + vh flip
2708 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2709 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
2710 break;
2711
2712 case 32: //gouraud
2713 //Probably not wort supporting.
2714 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2715 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
2716 break;
2717
2718 case 0:
2719 //no effect
2720 masked_stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
2721 break;
2722
2723
2724 default:
2725 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
2726
2727
2728 }
2729 } //end if not rotated
2730
2731 if ( rot != 0 ) //if rotated
2732 {
2733 switch(mode)
2734 {
2735 case 1:
2736 //transparent
2737 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2738 rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2739
2740 break;
2741
2742 case 2:
2743 //pivot?
2744 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
2745 //return an error, cannot both rotate and pivot
2746 break;
2747
2748 case 3:
2749 //pivot + trans
2750 //return an error, cannot both rotate and pivot
2751 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
2752 break;
2753
2754 case 4:
2755 //flip v
2756 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2757 rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2758 break;
2759
2760 case 5:
2761 //trans + v flip
2762 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2763 rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2764 break;
2765
2766 case 6:
2767 //pivot + v flip
2768 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
2769 //return an error, cannot both rotate and pivot
2770 break;
2771
2772 case 8:
2773 //flip h
2774 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
2775 //return an error, cannot both rotate and flip H
2776 break;
2777
2778 case 9:
2779 //trans + h flip
2780 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
2781 //return an error, cannot rotate and flip a trans sprite
2782 break;
2783
2784 case 10:
2785 //flip H and pivot
2786 //return error cannot pivot and h flip
2787 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
2788 break;
2789
2790 case 12:
2791 //vh flip
2792 //return an error, cannot rotate and VH flip a trans sprite
2793 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
2794 break;
2795
2796 case 13:
2797 //trans + vh flip
2798 //return an error, cannot rotate and VH flip a trans sprite
2799 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
2800 break;
2801
2802 case 14:
2803 //pivot and vh flip
2804 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
2805 //return error cannot both pivot and vh flip
2806 break;
2807
2808 case 16:
2809 //lit
2810 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2811 rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
2812 break;
2813
2814 case 18:
2815 //pivot, lit
2816 //return an error, cannot both rotate and pivot
2817 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
2818 break;
2819
2820 case 20:
2821 //lit + vflip
2822 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2823 rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
2824 break;
2825
2826 case 22:
2827 //Pivot, vflip, lit
2828 //return an error, cannot both rotate and pivot
2829 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
2830 break;
2831
2832 case 24:
2833 //lit + h flip
2834 //return an error, cannot both rotate and H flip
2835 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
2836 break;
2837
2838 case 26:
2839 //pivot + lit + hflip
2840 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
2841 //return error cannot pivot, lit, and flip
2842 break;
2843
2844 case 28:
2845 //lit + vh flip
2846 //return an error, cannot both rotate and VH flip
2847 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
2848 break;
2849
2850 case 32: //gouraud
2851 //Probably not wort supporting.
2852 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2853 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
2854 break;
2855
2856 case 0:
2857 //no effect.
2858 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2859 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2860 break;
2861
2862 default:
2863 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
2864
2865 }
2866 }
2867 } //end if stretched and masked
2868
2869 else //stretched, not masked
2870 {
2871 if ( rot == 0 ) //if not rotated
2872 {
2873 switch(mode) {
2874 case 1:
2875 //transparent
2876 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2877 draw_trans_sprite(bmp, subBmp, dx, dy);
2878 break;
2879
2880
2881 case 2:
2882 //pivot?
2883 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2884 pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2885 //Pivoting requires two more args
2886 break;
2887
2888 case 3:
2889 //pivot + trans
2890 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2891 pivot_sprite_trans(bmp, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot));
2892 break;
2893
2894 case 4:
2895 //flip v
2896 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2897 draw_sprite_v_flip(bmp, subBmp, dx, dy);
2898 break;
2899
2900 case 5:
2901 //trans + v flip
2902 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2903 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
2904 break;
2905
2906 case 6:
2907 //pivot + v flip
2908 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2909 pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2910 break;
2911
2912 case 8:
2913 //vlip h
2914 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2915 draw_sprite_h_flip(bmp, subBmp, dx, dy);
2916 break;
2917
2918 case 9:
2919 //trans + h flip
2920 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2921 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
2922 break;
2923
2924 case 10:
2925 //flip H and pivot
2926 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
2927 //return error cannot pivot and h flip
2928 break;
2929
2930 case 12:
2931 //vh flip
2932 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2933 draw_sprite_vh_flip(bmp, subBmp, dx, dy);
2934 break;
2935
2936 case 13:
2937 //trans + vh flip
2938 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2939 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
2940 break;
2941
2942 case 14:
2943 //pivot and vh flip
2944 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
2945 //return error cannot both pivot and vh flip
2946 break;
2947
2948 case 16:
2949 //lit
2950 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2951 draw_lit_sprite(bmp, subBmp, dx, dy, litcolour);
2952 break;
2953
2954 case 18:
2955 //pivot, lit
2956 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2957 pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
2958 break;
2959
2960 case 20:
2961 //lit + v flip
2962 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2963 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
2964 break;
2965
2966 case 22:
2967 //Pivot, vflip, lit
2968 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2969 pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
2970 break;
2971
2972 case 24:
2973 //lit + h flip
2974 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2975 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
2976 break;
2977
2978 case 26:
2979 //pivot + lit + hflip
2980 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
2981 //return error cannot pivot, lit, and flip
2982 break;
2983
2984 case 28:
2985 //lit + vh flip
2986 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2987 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
2988 break;
2989
2990 case 32: //gouraud
2991 //Probably not wort supporting.
2992 //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2993 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
2994 break;
2995
2996 case 0:
2997 //no effect
2998 stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
2999 break;
3000
3001
3002 default:
3003 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3004
3005
3006 }
3007 } //end if not rotated
3008
3009 if ( rot != 0 ) //if rotated
3010 {
3011 switch(mode)
3012 {
3013 case 1:
3014 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
3015 rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3016
3017 break;
3018
3019 case 2:
3020 //pivot?
3021 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3022 //return an error, cannot both rotate and pivot
3023 break;
3024
3025 case 3:
3026 //pivot + trans
3027 //return an error, cannot both rotate and pivot
3028 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3029 break;
3030
3031 case 4:
3032 //flip v
3033 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3034 rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3035 break;
3036
3037 case 5:
3038 //trans + v flip
3039 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3040 rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3041 break;
3042
3043 case 6:
3044 //pivot + v flip
3045 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3046 //return an error, cannot both rotate and pivot
3047 break;
3048
3049 case 8:
3050 //flip h
3051 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
3052 //return an error, cannot both rotate and flip H
3053 break;
3054
3055 case 9:
3056 //trans + h flip
3057 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
3058 //return an error, cannot rotate and flip a trans sprite
3059 break;
3060
3061 case 10:
3062 //flip H and pivot
3063 //return error cannot pivot and h flip
3064 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3065 break;
3066
3067 case 12:
3068 //vh flip
3069 //return an error, cannot rotate and VH flip a trans sprite
3070 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3071 break;
3072
3073 case 13:
3074 //trans + vh flip
3075 //return an error, cannot rotate and VH flip a trans sprite
3076 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3077 break;
3078
3079 case 14:
3080 //pivot and vh flip
3081 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3082 //return error cannot both pivot and vh flip
3083 break;
3084
3085 case 16:
3086 //lit
3087 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
3088 rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3089 break;
3090
3091 case 18:
3092 //pivot, lit
3093 //return an error, cannot both rotate and pivot
3094 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3095 break;
3096
3097 case 20:
3098 //lit + vflip
3099 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
3100 rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3101 break;
3102
3103 case 22:
3104 //Pivot, vflip, lit
3105 //return an error, cannot both rotate and pivot
3106 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3107 break;
3108
3109 case 24:
3110 //lit + h flip
3111 //return an error, cannot both rotate and H flip
3112 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
3113 break;
3114
3115 case 26:
3116 //pivot + lit + hflip
3117 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
3118 //return error cannot pivot, lit, and flip
3119 break;
3120
3121 case 28:
3122 //lit + vh flip
3123 //return an error, cannot both rotate and VH flip
3124 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3125 break;
3126
3127 case 32: //gouraud
3128 //Probably not wort supporting.
3129 //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3130 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3131 break;
3132
3133 case 0:
3134 //no effect.
3135 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3136 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3137 break;
3138
3139 default:
3140 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3141
3142 }
3143 }
3144
3145 } //end if stretched, but not masked
3146 }
3147 else //not stretched
3148 {
3149
3150 if(masked) //if masked, but not stretched
3151 {
3152
3153 if ( rot == 0 ) //if not rotated
3154 {
3155 switch(mode)
3156 {
3157 case 1:
3158 //transparent
3159 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3160 draw_trans_sprite(bmp, subBmp, dx, dy);
3161 break;
3162
3163
3164 case 2:
3165 //pivot?
3166 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3167 pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3168 //Pivoting requires two more args
3169 break;
3170
3171 case 3:
3172 //pivot + trans
3173 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3174 pivot_sprite_trans(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3175 break;
3176
3177 case 4:
3178 //flip v
3179 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3180 draw_sprite_v_flip(bmp, subBmp, dx, dy);
3181 break;
3182
3183 case 5:
3184 //trans + v flip
3185 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3186 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
3187 break;
3188
3189 case 6:
3190 //pivot + v flip
3191 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3192 pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3193 break;
3194
3195 case 8:
3196 //vlip h
3197 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3198 draw_sprite_h_flip(bmp, subBmp, dx, dy);
3199 break;
3200
3201 case 9:
3202 //trans + h flip
3203 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3204 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
3205 break;
3206
3207 case 10:
3208 //flip H and pivot
3209 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3210 //return error cannot pivot and h flip
3211 break;
3212
3213 case 12:
3214 //vh flip
3215 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3216 draw_sprite_vh_flip(bmp, subBmp, dx, dy);
3217 break;
3218
3219 case 13:
3220 //trans + vh flip
3221 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3222 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
3223 break;
3224
3225 case 14:
3226 //pivot and vh flip
3227 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3228 //return error cannot both pivot and vh flip
3229 break;
3230
3231 case 16:
3232 //lit
3233 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3234 draw_lit_sprite(bmp, subBmp, dx, dy, litcolour);
3235 break;
3236
3237 case 18:
3238 //pivot, lit
3239 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3240 pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3241 break;
3242
3243 case 20:
3244 //lit + v flip
3245 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3246 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
3247 break;
3248
3249 case 22:
3250 //Pivot, vflip, lit
3251 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3252 pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3253 break;
3254
3255 case 24:
3256 //lit + h flip
3257 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3258 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
3259 break;
3260
3261 case 26:
3262 //pivot + lit + hflip
3263 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
3264 //return error cannot pivot, lit, and flip
3265 break;
3266
3267 case 28:
3268 //lit + vh flip
3269 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3270 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
3271 break;
3272
3273 case 32: //gouraud
3274 //Probably not wort supporting.
3275 //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3276 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3277 break;
3278
3279 case 0:
3280 //no effect
3281 masked_blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
3282 break;
3283
3284
3285 default:
3286 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3287
3288
3289 }
3290 } //end if not rotated
3291
3292 if ( rot != 0 ) //if rotated
3293 {
3294 switch(mode)
3295 {
3296 case 1:
3297 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); //transparent
3298 rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3299
3300 break;
3301
3302 case 2:
3303 //pivot?
3304 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3305 //return an error, cannot both rotate and pivot
3306 break;
3307
3308 case 3:
3309 //pivot + trans
3310 //return an error, cannot both rotate and pivot
3311 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3312 break;
3313
3314 case 4:
3315 //flip v
3316 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3317 rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3318 break;
3319
3320 case 5:
3321 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip
3322 rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3323 break;
3324
3325 case 6:
3326 //pivot + v flip
3327 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3328 //return an error, cannot both rotate and pivot
3329 break;
3330
3331 case 8:
3332 //flip h
3333 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
3334 //return an error, cannot both rotate and flip H
3335 break;
3336
3337 case 9:
3338 //trans + h flip
3339 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
3340 //return an error, cannot rotate and flip a trans sprite
3341 break;
3342
3343 case 10:
3344 //flip H and pivot
3345 //return error cannot pivot and h flip
3346 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3347 break;
3348
3349 case 12:
3350 //vh flip
3351 //return an error, cannot rotate and VH flip a trans sprite
3352 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3353 break;
3354
3355 case 13:
3356 //trans + vh flip
3357 //return an error, cannot rotate and VH flip a trans sprite
3358 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3359 break;
3360
3361 case 14:
3362 //pivot and vh flip
3363 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3364 //return error cannot both pivot and vh flip
3365 break;
3366
3367 case 16:
3368 //lit
3369 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3370 rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3371 break;
3372
3373 case 18:
3374 //pivot, lit
3375 //return an error, cannot both rotate and pivot
3376 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3377 break;
3378
3379 case 20:
3380 //lit + vflip
3381 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3382 rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3383 break;
3384
3385 case 22:
3386 //Pivot, vflip, lit
3387 //return an error, cannot both rotate and pivot
3388 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3389 break;
3390
3391 case 24:
3392 //lit + h flip
3393 //return an error, cannot both rotate and H flip
3394 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
3395 break;
3396
3397 case 26:
3398 //pivot + lit + hflip
3399 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
3400 //return error cannot pivot, lit, and flip
3401 break;
3402
3403 case 28:
3404 //lit + vh flip
3405 //return an error, cannot both rotate and VH flip
3406 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3407 break;
3408
3409 case 32: //gouraud
3410 //Probably not wort supporting.
3411 //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3412 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3413 break;
3414
3415 case 0:
3416 //no effect.
3417 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3418 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3419 break;
3420
3421 default:
3422 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3423
3424 }
3425 } //end rtated, masked
3426 } //end if masked
3427
3428 else //not masked, and not stretched; just blit
3429 {
3430
3431 if ( rot == 0 ) //if not rotated
3432 {
3433 switch(mode)
3434 {
3435 case 1:
3436 //transparent
3437 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3438 draw_trans_sprite(bmp, subBmp, dx, dy);
3439 break;
3440
3441
3442 case 2:
3443 //pivot?
3444 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3445 pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3446 //Pivoting requires two more args
3447 break;
3448
3449 case 3:
3450 //pivot + trans
3451 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3452 pivot_sprite_trans(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3453 break;
3454
3455 case 4:
3456 //flip v
3457 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3458 draw_sprite_v_flip(bmp, subBmp, dx, dy);
3459 break;
3460
3461 case 5:
3462 //trans + v flip
3463 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3464 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
3465 break;
3466
3467 case 6:
3468 //pivot + v flip
3469 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3470 pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3471 break;
3472
3473 case 8:
3474 //vlip h
3475 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3476 draw_sprite_h_flip(bmp, subBmp, dx, dy);
3477 break;
3478
3479 case 9:
3480 //trans + h flip
3481 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3482 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
3483 break;
3484
3485 case 10:
3486 //flip H and pivot
3487 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3488 //return error cannot pivot and h flip
3489 break;
3490
3491 case 12:
3492 //vh flip
3493 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3494 draw_sprite_vh_flip(bmp, subBmp, dx, dy);
3495 break;
3496
3497 case 13:
3498 //trans + vh flip
3499 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3500 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
3501 break;
3502
3503 case 14:
3504 //pivot and vh flip
3505 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3506 //return error cannot both pivot and vh flip
3507 break;
3508
3509 case 16:
3510 //lit
3511 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3512 draw_lit_sprite(bmp, subBmp, dx, dy, litcolour);
3513 break;
3514
3515 case 18:
3516 //pivot, lit
3517 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3518 pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3519 break;
3520
3521 case 20:
3522 //lit + v flip
3523 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3524 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
3525 break;
3526
3527 case 22:
3528 //Pivot, vflip, lit
3529 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3530 pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3531 break;
3532
3533 case 24:
3534 //lit + h flip
3535 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3536 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
3537 break;
3538
3539 case 26:
3540 //pivot + lit + hflip
3541 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
3542 //return error cannot pivot, lit, and flip
3543 break;
3544
3545 case 28:
3546 //lit + vh flip
3547 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3548 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
3549 break;
3550
3551 case 32: //gouraud
3552 //Probably not wort supporting.
3553 //blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3554 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3555 break;
3556
3557 case 0:
3558 //no effect
3559 blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
3560 break;
3561
3562
3563 default:
3564 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3565
3566
3567 }
3568 } //end if not rotated
3569
3570 if ( rot != 0 ) //if rotated
3571 {
3572 switch(mode)
3573 {
3574 case 1:
3575 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);//transparent
3576 rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3577
3578 break;
3579
3580 case 2:
3581 //pivot?
3582 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3583 //return an error, cannot both rotate and pivot
3584 break;
3585
3586 case 3:
3587 //pivot + trans
3588 //return an error, cannot both rotate and pivot
3589 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3590 break;
3591
3592 case 4:
3593 //flip v
3594 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3595 rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3596 break;
3597
3598 case 5:
3599 //trans + v flip
3600 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3601 rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3602 break;
3603
3604 case 6:
3605 //pivot + v flip
3606 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3607 //return an error, cannot both rotate and pivot
3608 break;
3609
3610 case 8:
3611 //flip h
3612 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
3613 //return an error, cannot both rotate and flip H
3614 break;
3615
3616 case 9:
3617 //trans + h flip
3618 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
3619 //return an error, cannot rotate and flip a trans sprite
3620 break;
3621
3622 case 10:
3623 //flip H and pivot
3624 //return error cannot pivot and h flip
3625 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3626 break;
3627
3628 case 12:
3629 //vh flip
3630 //return an error, cannot rotate and VH flip a trans sprite
3631 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3632 break;
3633
3634 case 13:
3635 //trans + vh flip
3636 //return an error, cannot rotate and VH flip a trans sprite
3637 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3638 break;
3639
3640 case 14:
3641 //pivot and vh flip
3642 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3643 //return error cannot both pivot and vh flip
3644 break;
3645
3646 case 16:
3647 //lit
3648 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3649 rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3650 break;
3651
3652 case 18:
3653 //pivot, lit
3654 //return an error, cannot both rotate and pivot
3655 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3656 break;
3657
3658 case 20:
3659 //lit + vflip
3660 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3661 rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3662 break;
3663
3664 case 22:
3665 //Pivot, vflip, lit
3666 //return an error, cannot both rotate and pivot
3667 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3668 break;
3669
3670 case 24:
3671 //lit + h flip
3672 //return an error, cannot both rotate and H flip
3673 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
3674 break;
3675
3676 case 26:
3677 //pivot + lit + hflip
3678 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
3679 //return error cannot pivot, lit, and flip
3680 break;
3681
3682 case 28:
3683 //lit + vh flip
3684 //return an error, cannot both rotate and VH flip
3685 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3686 break;
3687
3688 case 32: //gouraud
3689 //Probably not wort supporting.
3690 //blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3691 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3692 break;
3693
3694 case 0:
3695 //no effect.
3696 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3697 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3698 break;
3699
3700 default:
3701 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3702
3703 }
3704 } //end if rotated
3705 } //end if not masked
3706 } //end if not stretched
3707
3708 //cleanup
3709 if(subBmp)
3710 {
3711 script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap.
3712 }
3713 }
3714
3715
3716 void do_drawquad3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
3717 {
3718 //sdci[1]=layer
3719 //sdci[2]=pos[12]
3720 //sdci[3]=uv[8]
3721 //sdci[4]=color[4]
3722 //sdci[5]=size[2]
3723 //sdci[6]=flip
3724 //sdci[7]=tile/combo
3725 //sdci[8]=polytype
3726
3727 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
3728
3729 if(!v_ptr)
3730 {
3731 al_trace("Quad3d: Vector pointer is null! Internal error. \n");
3732 return;
3733 }
3734
3735 std::vector<int32_t> &v = *v_ptr;
3736
3737 if(v.empty())
3738 return;
3739
3740 int32_t* pos = &v[0];
3741 int32_t* uv = &v[12];
3742 int32_t* col = &v[20];
3743 int32_t* size = &v[24];
3744
3745 int32_t w = size[0]; //magic numerical constants... yuck.
3746 int32_t h = size[1];
3747 int32_t flip = (sdci[6]/10000)&3;
3748 int32_t tile = sdci[7]/10000;
3749 int32_t polytype = sdci[8]/10000;
3750
3751 polytype = vbound(polytype, 0, 14);
3752
3753 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
3754 {
3755 Z_message("Quad3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
3756 return; //non power of two error
3757 }
3758
3759 int32_t tex_width = w*16;
3760 int32_t tex_height = h*16;
3761
3762 bool mustDestroyBmp = false;
3763 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
3764
3765 if(!tex)
3766 {
3767 mustDestroyBmp = true;
3768 tex = create_bitmap_ex(8, tex_width, tex_height);
3769 clear_bitmap(tex);
3770 }
3771
3772 if(tile > 0) // TILE
3773 {
3774 TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
3775 }
3776 else // COMBO
3777 {
3778 const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ];
3779 const int32_t tiletodraw = combo_tile(c, 0, 0);
3780 flip = flip ^ c.flip;
3781
3782 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
3783 }
3784
3785 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
3786 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
3787 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
3788 V3D_f V4 = { static_cast<float>(pos[9]+xoffset), static_cast<float>(pos[10]+yoffset), static_cast<float>(pos[11]), static_cast<float>(uv[6]), static_cast<float>(uv[7]), col[3] };
3789
3790 quad3d_f(bmp, polytype, tex, &V1, &V2, &V3, &V4);
3791
3792 if(mustDestroyBmp)
3793 destroy_bitmap(tex);
3794
3795 }
3796
3797
3798
3799 void do_drawtriangle3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
3800 {
3801 //sdci[1]=layer
3802 //sdci[2]=pos[9]
3803 //sdci[3]=uv[6]
3804 //sdci[4]=color[3]
3805 //sdci[5]=size[2]
3806 //sdci[6]=flip
3807 //sdci[7]=tile/combo
3808 //sdci[8]=polytype
3809
3810 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
3811
3812 if(!v_ptr)
3813 {
3814 al_trace("Triange3d: Vector pointer is null! Internal error. \n");
3815 return;
3816 }
3817
3818 std::vector<int32_t> &v = *v_ptr;
3819
3820 if(v.empty())
3821 return;
3822
3823 int32_t* pos = &v[0];
3824 int32_t* uv = &v[9];
3825 int32_t* col = &v[15];
3826 int32_t* size = &v[18];
3827
3828 int32_t w = size[0]; //magic numerical constants... yuck.
3829 int32_t h = size[1];
3830 int32_t flip = (sdci[6]/10000)&3;
3831 int32_t tile = sdci[7]/10000;
3832 int32_t polytype = sdci[8]/10000;
3833
3834 polytype = vbound(polytype, 0, 14);
3835
3836 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
3837 {
3838 Z_message("Triangle3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
3839 return; //non power of two error
3840 }
3841
3842 int32_t tex_width = w*16;
3843 int32_t tex_height = h*16;
3844
3845 bool mustDestroyBmp = false;
3846 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
3847
3848 if(!tex)
3849 {
3850 mustDestroyBmp = true;
3851 tex = create_bitmap_ex(8, tex_width, tex_height);
3852 clear_bitmap(tex);
3853 }
3854
3855 if(tile > 0) // TILE
3856 {
3857 TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
3858 }
3859 else // COMBO
3860 {
3861 const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ];
3862 const int32_t tiletodraw = combo_tile(c, 0, 0);
3863 flip = flip ^ c.flip;
3864
3865 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
3866 }
3867
3868 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
3869 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
3870 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
3871
3872 triangle3d_f(bmp, polytype, tex, &V1, &V2, &V3);
3873
3874 if(mustDestroyBmp)
3875 destroy_bitmap(tex);
3876
3877 }
3878
3879 7818 void bmp_do_rectr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
3880 {
3881 //Z_scripterrlog("rect sdci[13] is: %d\n", sdci[13]);
3882 //sdci[1]=layer
3883 //sdci[2]=x
3884 //sdci[3]=y
3885 //sdci[4]=x2
3886 //sdci[5]=y2
3887 //sdci[6]=color
3888 //sdci[7]=scale factor
3889 //sdci[8]=rotation anchor x
3890 //sdci[9]=rotation anchor y
3891 //sdci[10]=rotation angle
3892 //sdci[11]=fill
3893 //sdci[12]=opacity
3894 //sdci[17] Bitmap Pointer
3895
1/2
✓ Branch 0 taken 7818 times.
✗ Branch 1 not taken.
7818 if(sdci[7]==0) //scale
3896 {
3897 return;
3898 }
3899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7818 times.
7818 if ( sdci[17] <= 0 )
3900 {
3901 Z_scripterrlog("bitmap->Rectangle() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
3902 return;
3903 }
3904 7818 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
3905
1/2
✓ Branch 0 taken 7818 times.
✗ Branch 1 not taken.
7818 if ( refbmp == NULL ) return;
3906
3907
2/4
✓ Branch 0 taken 7818 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7818 times.
7818 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
3908
3909 7818 int32_t x1=sdci[2]/10000;
3910 7818 int32_t y1=sdci[3]/10000;
3911 7818 int32_t x2=sdci[4]/10000;
3912 7818 int32_t y2=sdci[5]/10000;
3913
3914
3915
2/2
✓ Branch 0 taken 7814 times.
✓ Branch 1 taken 4 times.
7818 if(x1>x2)
3916 {
3917 4 zc_swap(x1,x2);
3918 4 }
3919
3920
2/2
✓ Branch 0 taken 7814 times.
✓ Branch 1 taken 4 times.
7818 if(y1>y2)
3921 {
3922 4 zc_swap(y1,y2);
3923 4 }
3924
3925
1/2
✓ Branch 0 taken 7818 times.
✗ Branch 1 not taken.
7818 if(sdci[7] != 10000)
3926 {
3927 int32_t w=x2-x1+1;
3928 int32_t h=y2-y1+1;
3929 int32_t w2=(w*sdci[7])/10000;
3930 int32_t h2=(h*sdci[7])/10000;
3931 x1=x1-((w2-w)/2);
3932 x2=x2+((w2-w)/2);
3933 y1=y1-((h2-h)/2);
3934 y2=y2+((h2-h)/2);
3935 }
3936
3937 7818 int32_t color=sdci[6]/10000;
3938
3939
2/2
✓ Branch 0 taken 7690 times.
✓ Branch 1 taken 128 times.
7818 if(sdci[12]/10000<=127) //translucent
3940 {
3941 128 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
3942 128 }
3943
3944
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 7722 times.
7818 if(sdci[10]==0) //no rotation
3945 {
3946
2/2
✓ Branch 0 taken 7710 times.
✓ Branch 1 taken 12 times.
7722 if(sdci[11]) //filled
3947 {
3948 7710 rectfill(refbmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
3949 7710 }
3950 else //outline
3951 {
3952 12 rect(refbmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
3953 }
3954 7722 }
3955 else //rotate
3956 {
3957 int32_t xy[16];
3958 96 int32_t rx=sdci[8]/10000;
3959 96 int32_t ry=sdci[9]/10000;
3960 96 fixed ra1=itofix(sdci[10]%10000)/10000;
3961 96 fixed ra2=itofix(sdci[10]/10000);
3962 96 fixed ra=ra1+ra2;
3963 96 ra = (ra/360)*256;
3964
3965 96 fixed fcosa = fixcos(ra);
3966 96 fixed fsina = fixsin(ra);
3967
3968 96 xy[ 0]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry))); //x1
3969 96 xy[ 1]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry))); //y1
3970 96 xy[ 2]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y1 - ry))); //x2
3971 96 xy[ 3]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y1 - ry))); //y1
3972 96 xy[ 4]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry))); //x2
3973 96 xy[ 5]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry))); //y2
3974 96 xy[ 6]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y2 - ry))); //x1
3975 96 xy[ 7]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y2 - ry))); //y2
3976 96 xy[ 8]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry + 1))); //x1
3977 96 xy[ 9]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry + 1))); //y1
3978 96 xy[10]=xoffset+rx + fixtoi((fcosa * (x2 - rx - 1) - fsina * (y1 - ry))); //x2
3979 96 xy[11]=yoffset+ry + fixtoi((fsina * (x2 - rx - 1) + fcosa * (y1 - ry))); //y1
3980 96 xy[12]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry - 1))); //x2
3981 96 xy[13]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry - 1))); //y2
3982 96 xy[14]=xoffset+rx + fixtoi((fcosa * (x1 - rx + 1) - fsina * (y2 - ry))); //x1
3983 96 xy[15]=yoffset+ry + fixtoi((fsina * (x1 - rx + 1) + fcosa * (y2 - ry))); //y2
3984
3985
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(sdci[11]) //filled
3986 {
3987 96 polygon(refbmp, 4, xy, color);
3988 96 }
3989 else //outline
3990 {
3991 line(refbmp, xy[0], xy[1], xy[10], xy[11], color);
3992 line(refbmp, xy[2], xy[3], xy[12], xy[13], color);
3993 line(refbmp, xy[4], xy[5], xy[14], xy[15], color);
3994 line(refbmp, xy[6], xy[7], xy[ 8], xy[ 9], color);
3995 }
3996 }
3997
3998 7818 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
3999 7818 }
4000
4001 void bmp_do_framer(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4002 {
4003 //sdci[1]=layer
4004 //sdci[2]=x
4005 //sdci[3]=y
4006 //sdci[4]=tile
4007 //sdci[5]=cset
4008 //sdci[6]=width
4009 //sdci[7]=height
4010 //sdci[8]=overlay
4011 //sdci[9]=opacity
4012
4013 if ( sdci[17] <= 0 )
4014 {
4015 Z_scripterrlog("bitmap->DrawFrame() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4016 return;
4017 }
4018 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4019 if ( refbmp == NULL ) return;
4020
4021 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4022
4023 int32_t x=sdci[2]/10000;
4024 int32_t y=sdci[3]/10000;
4025
4026 int32_t tile=sdci[4]/10000;
4027 int32_t cs=sdci[5]/10000;
4028 int32_t w=sdci[6]/10000;
4029 int32_t h=sdci[7]/10000;
4030 bool overlay=sdci[8];
4031 bool trans=(sdci[9]/10000<=127);
4032
4033 frame2x2(refbmp, x + xoffset, y + yoffset, tile, cs, w, h, 0, overlay, trans);
4034 }
4035
4036
4037 1480 void bmp_do_circler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4038 {
4039 //sdci[1]=layer
4040 //sdci[2]=x
4041 //sdci[3]=y
4042 //sdci[4]=radius
4043 //sdci[5]=color
4044 //sdci[6]=scale factor
4045 //sdci[7]=rotation anchor x
4046 //sdci[8]=rotation anchor y
4047 //sdci[9]=rotation angle
4048 //sdci[10]=fill
4049 //sdci[11]=opacity
4050 //sdci[17] Bitmap Pointer
4051
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(sdci[6]==0) //scale
4052 {
4053 return;
4054 }
4055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1480 times.
1480 if ( sdci[17] <= 0 )
4056 {
4057 Z_scripterrlog("bitmap->Circle() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4058 return;
4059 }
4060 1480 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4061
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if ( refbmp == NULL ) return;
4062
4063
2/4
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1480 times.
1480 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4064
4065 1480 int32_t x1=sdci[2]/10000;
4066 1480 int32_t y1=sdci[3]/10000;
4067 1480 qword r=sdci[4];
4068
4069
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(sdci[6] != 10000)
4070 {
4071 r*=sdci[6];
4072 r/=10000;
4073 }
4074
4075 1480 r/=10000;
4076 1480 int32_t color=sdci[5]/10000;
4077
4078
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(sdci[11]/10000<=127) //translucent
4079 {
4080 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4081 }
4082
4083
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1480 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1480 if(sdci[9]!=0&&(sdci[2]!=sdci[7]||sdci[3]!=sdci[8])) //rotation
4084 {
4085 int32_t xy[2];
4086 int32_t rx=sdci[7]/10000;
4087 int32_t ry=sdci[8]/10000;
4088 fixed ra1=itofix(sdci[9]%10000)/10000;
4089 fixed ra2=itofix(sdci[9]/10000);
4090 fixed ra=ra1+ra2;
4091 ra = (ra/360)*256;
4092
4093 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4094 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4095 x1=xy[0];
4096 y1=xy[1];
4097 }
4098
4099
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(sdci[10]) //filled
4100 {
4101 1480 circlefill(refbmp, x1+xoffset, y1+yoffset, r, color);
4102 1480 }
4103 else //outline
4104 {
4105 circle(refbmp, x1+xoffset, y1+yoffset, r, color);
4106 }
4107
4108 1480 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4109 1480 }
4110
4111
4112 void bmp_do_arcr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4113 {
4114 //sdci[1]=layer
4115 //sdci[2]=x
4116 //sdci[3]=y
4117 //sdci[4]=radius
4118 //sdci[5]=start angle
4119 //sdci[6]=end angle
4120 //sdci[7]=color
4121 //sdci[8]=scale factor
4122 //sdci[9]=rotation anchor x
4123 //sdci[10]=rotation anchor y
4124 //sdci[11]=rotation angle
4125 //sdci[12]=closed
4126 //sdci[13]=fill
4127 //sdci[14]=opacity
4128 //sdci[17] Bitmap Pointer
4129
4130 if(sdci[8]==0) //scale
4131 {
4132 return;
4133 }
4134 if ( sdci[17] <= 0 )
4135 {
4136 Z_scripterrlog("bitmap->Arc() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4137 return;
4138 }
4139 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4140 if ( refbmp == NULL ) return;
4141
4142 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4143
4144 int32_t cx=sdci[2]/10000;
4145 int32_t cy=sdci[3]/10000;
4146 qword r=sdci[4];
4147
4148 if(sdci[8] != 10000)
4149 {
4150 r*=sdci[8];
4151 r/=10000;
4152 }
4153
4154 r/=10000;
4155
4156 int32_t color=sdci[7]/10000;
4157
4158 fixed ra1=itofix(sdci[11]%10000)/10000;
4159 fixed ra2=itofix(sdci[11]/10000);
4160 fixed ra=ra1+ra2;
4161 ra = (ra/360)*256;
4162
4163
4164 fixed a1=itofix(sdci[5]%10000)/10000;
4165 fixed a2=itofix(sdci[5]/10000);
4166 fixed sa=a1+a2;
4167 sa = (sa/360)*256;
4168
4169 a1=itofix(sdci[6]%10000)/10000;
4170 a2=itofix(sdci[6]/10000);
4171 fixed ea=a1+a2;
4172 ea = (ea/360)*256;
4173
4174 if(sdci[11]!=0) //rotation
4175 {
4176 int32_t rx=sdci[9]/10000;
4177 int32_t ry=sdci[10]/10000;
4178
4179 cx=rx + fixtoi((fixcos(ra) * (cx - rx) - fixsin(ra) * (cy - ry))); //x1
4180 cy=ry + fixtoi((fixsin(ra) * (cx - rx) + fixcos(ra) * (cy - ry))); //y1
4181 ea-=ra;
4182 sa-=ra;
4183 }
4184
4185 int32_t fx=cx+fixtoi(fixcos(-(ea+sa)/2)*r/2);
4186 int32_t fy=cy+fixtoi(fixsin(-(ea+sa)/2)*r/2);
4187
4188 if(sdci[12]) //closed
4189 {
4190 if(sdci[13]) //filled
4191 {
4192 clear_bitmap(prim_bmp);
4193 arc(prim_bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
4194 line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color);
4195 line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color);
4196 int fillx = zc_max(0,fx)+xoffset;
4197 int filly = zc_max(0,fy)+yoffset;
4198 zprint2("bitmap->Arc fill at prim_bmp (%d,%d) - 512x512\n", fillx, filly);
4199 floodfill(prim_bmp, fillx, filly, color);
4200
4201 if(sdci[14]/10000<=127) //translucent
4202 {
4203 draw_trans_sprite(refbmp, prim_bmp, 0,0);
4204 }
4205 else
4206 {
4207 draw_sprite(refbmp, prim_bmp, 0,0);
4208 }
4209 }
4210 else
4211 {
4212 arc(refbmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
4213 line(refbmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color);
4214 line(refbmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color);
4215 }
4216 }
4217 else
4218 {
4219 if(sdci[14]/10000<=127) //translucent
4220 {
4221 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4222 }
4223
4224 arc(refbmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
4225 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4226 }
4227 }
4228
4229
4230 502 void bmp_do_ellipser(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4231 {
4232 //sdci[1]=layer
4233 //sdci[2]=x
4234 //sdci[3]=y
4235 //sdci[4]=radiusx
4236 //sdci[5]=radiusy
4237 //sdci[6]=color
4238 //sdci[7]=scale factor
4239 //sdci[8]=rotation anchor x
4240 //sdci[9]=rotation anchor y
4241 //sdci[10]=rotation angle
4242 //sdci[11]=fill
4243 //sdci[12]=opacity
4244 //sdci[17] Bitmap Pointer
4245
4246
1/2
✓ Branch 0 taken 502 times.
✗ Branch 1 not taken.
502 if(sdci[7]==0) //scale
4247 {
4248 return;
4249 }
4250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 502 times.
502 if ( sdci[17] <= 0 )
4251 {
4252 Z_scripterrlog("bitmap->Ellipse() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4253 return;
4254 }
4255 502 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4256
1/2
✓ Branch 0 taken 502 times.
✗ Branch 1 not taken.
502 if ( refbmp == NULL ) return;
4257
4258 502 int32_t x1=sdci[2]/10000;
4259 502 int32_t y1=sdci[3]/10000;
4260 502 int32_t radx=sdci[4]/10000;
4261 502 radx*=sdci[7]/10000;
4262 502 int32_t rady=sdci[5]/10000;
4263 502 rady*=sdci[7]/10000;
4264 502 int32_t color=sdci[6]/10000;
4265 502 float rotation = sdci[10]/10000;
4266
4267 502 int32_t rx=sdci[8]/10000;
4268 502 int32_t ry=sdci[9]/10000;
4269 502 fixed ra1=itofix(sdci[10]%10000)/10000;
4270 502 fixed ra2=itofix(sdci[10]/10000);
4271 502 fixed ra=ra1+ra2;
4272 502 ra = (ra/360)*256;
4273
4274
2/4
✓ Branch 0 taken 502 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 502 times.
✗ Branch 3 not taken.
502 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4275
4276 int32_t xy[2];
4277 502 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4278 502 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4279 502 x1=xy[0];
4280 502 y1=xy[1];
4281
4282
6/8
✓ Branch 0 taken 498 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 494 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 494 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 494 times.
502 if(radx<1||rady<1||radx>255||rady>255) return;
4283
4284 494 BITMAP* bitty = script_drawing_commands.AquireSubBitmap(radx*2+1, rady*2+1);
4285
4286
2/4
✓ Branch 0 taken 494 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 494 times.
494 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4287
4288
1/2
✓ Branch 0 taken 494 times.
✗ Branch 1 not taken.
494 if(sdci[11]) //filled
4289 {
4290
4291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 494 times.
494 if(sdci[12]/10000<128) //translucent
4292 {
4293 clear_bitmap(prim_bmp);
4294 ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color);
4295 rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
4296 draw_trans_sprite(refbmp, prim_bmp, 0, 0);
4297 }
4298 else // no opacity
4299 {
4300
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 62 times.
494 ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color);
4301 494 rotate_sprite(refbmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
4302 }
4303 494 }
4304 else //not filled
4305 {
4306 if(sdci[12]/10000<128) //translucent
4307 {
4308 clear_bitmap(prim_bmp);
4309 ellipse(bitty, radx, rady, radx, rady, color==0?255:color);
4310 rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
4311 draw_trans_sprite(refbmp, prim_bmp, 0, 0);
4312 }
4313 else // no opacity
4314 {
4315 ellipse(bitty, radx, rady, radx, rady, color==0?255:color);
4316 rotate_sprite(refbmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
4317 }
4318 }
4319
4320 // Since 0 is the transparent color, the stuff above will fail if the ellipse color is also 0.
4321 // Instead, it uses color 255 and replaces it afterward. That'll also screw up color 255 around
4322 // the ellipse, but it shouldn't be used anyway.
4323
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 62 times.
494 if(color==0)
4324 {
4325 // This is very slow, so check the smallest possible square
4326
3/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
62 int32_t endx=zc_min(bmp->w-1, x1+zc_max(radx, rady));
4327
3/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
62 int32_t endy=zc_min(bmp->h-1, y1+zc_max(radx, rady));
4328
4329
6/8
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4430 times.
✓ Branch 7 taken 62 times.
4492 for(int32_t y=zc_max(0, y1-zc_max(radx, rady)); y<=endy; y++)
4330
6/8
✓ Branch 0 taken 4430 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3052 times.
✓ Branch 3 taken 1378 times.
✓ Branch 4 taken 1378 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 467774 times.
✓ Branch 7 taken 4430 times.
472204 for(int32_t x=zc_max(0, x1-zc_max(radx, rady)); x<=endx; x++)
4331
2/2
✓ Branch 0 taken 238992 times.
✓ Branch 1 taken 228782 times.
696556 if(getpixel(refbmp, x, y)==255)
4332 233212 putpixel(refbmp, x, y, 0);
4333 62 }
4334
4335 494 script_drawing_commands.ReleaseSubBitmap(bitty);
4336 502 }
4337
4338
4339 144 void bmp_do_liner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4340 {
4341 //sdci[1]=layer
4342 //sdci[2]=x
4343 //sdci[3]=y
4344 //sdci[4]=x2
4345 //sdci[5]=y2
4346 //sdci[6]=color
4347 //sdci[7]=scale factor
4348 //sdci[8]=rotation anchor x
4349 //sdci[9]=rotation anchor y
4350 //sdci[10]=rotation angle
4351 //sdci[11]=opacity
4352 //sdci[17] Bitmap Pointer
4353
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(sdci[7]==0) //scale
4354 {
4355 return;
4356 }
4357
4358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if ( sdci[17] <= 0 )
4359 {
4360 Z_scripterrlog("bitmap->Line() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4361 return;
4362 }
4363
4364 144 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4365
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if ( refbmp == NULL ) return;
4366
4367 144 int32_t x1=sdci[2]/10000;
4368 144 int32_t y1=sdci[3]/10000;
4369 144 int32_t x2=sdci[4]/10000;
4370 144 int32_t y2=sdci[5]/10000;
4371
4372
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(sdci[7] != 10000)
4373 {
4374 int32_t w=x2-x1+1;
4375 int32_t h=y2-y1+1;
4376 int32_t w2=int32_t(w*((double)sdci[7]/10000.0));
4377 int32_t h2=int32_t(h*((double)sdci[7]/10000.0));
4378 x1=x1-((w2-w)/2);
4379 x2=x2+((w2-w)/2);
4380 y1=y1-((h2-h)/2);
4381 y2=y2+((h2-h)/2);
4382 }
4383
4384 144 int32_t color=sdci[6]/10000;
4385
4386
2/4
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144 times.
144 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4387
4388
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(sdci[11]/10000<=127) //translucent
4389 {
4390 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4391 }
4392
4393
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(sdci[10]!=0) //rotation
4394 {
4395 int32_t xy[4];
4396 int32_t rx=sdci[8]/10000;
4397 int32_t ry=sdci[9]/10000;
4398 fixed ra1=itofix(sdci[10]%10000)/10000;
4399 fixed ra2=itofix(sdci[10]/10000);
4400 fixed ra=ra1+ra2;
4401
4402 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4403 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4404 xy[ 2]=rx + fixtoi((fixcos(ra) * (x2 - rx) - fixsin(ra) * (y2 - ry))); //x2
4405 xy[ 3]=ry + fixtoi((fixsin(ra) * (x2 - rx) + fixcos(ra) * (y2 - ry))); //y2
4406 x1=xy[0];
4407 y1=xy[1];
4408 x2=xy[2];
4409 y2=xy[3];
4410 }
4411
4412 144 line(refbmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
4413 144 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4414 144 }
4415
4416
4417 void bmp_do_spliner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4418 {
4419 /* layer, x1, y1, x2, y2, x3, y3, x4, y4, color, opacity */
4420 //sdci[17] Bitmap Pointer
4421
4422 int32_t points[8] = { xoffset + (sdci[2]/10000), yoffset + (sdci[3]/10000),
4423 xoffset + (sdci[4]/10000), yoffset + (sdci[5]/10000),
4424 xoffset + (sdci[6]/10000), yoffset + (sdci[7]/10000),
4425 xoffset + (sdci[8]/10000), yoffset + (sdci[9]/10000)
4426 };
4427
4428 if(sdci[11]/10000 < 128) //translucent
4429 {
4430 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4431 }
4432
4433 if ( sdci[17] <= 0 )
4434 {
4435 Z_scripterrlog("bitmap->Spline() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4436 return;
4437 }
4438
4439 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4440 if ( refbmp == NULL ) return;
4441
4442 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4443
4444 spline(refbmp, points, sdci[10]/10000);
4445
4446 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4447 }
4448
4449
4450 80910 void bmp_do_putpixelr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4451 {
4452 //sdci[1]=layer
4453 //sdci[2]=x
4454 //sdci[3]=y
4455 //sdci[4]=color
4456 //sdci[5]=rotation anchor x
4457 //sdci[6]=rotation anchor y
4458 //sdci[7]=rotation angle
4459 //sdci[8]=opacity
4460 //sdci[17] Bitmap Pointer
4461 80910 int32_t x1=sdci[2]/10000;
4462 80910 int32_t y1=sdci[3]/10000;
4463 80910 int32_t color=sdci[4]/10000;
4464
4465
1/2
✓ Branch 0 taken 80910 times.
✗ Branch 1 not taken.
80910 if(sdci[8]/10000<=127) //translucent
4466 {
4467 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4468 }
4469
4470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80910 times.
80910 if ( sdci[17] <= 0 )
4471 {
4472 Z_scripterrlog("bitmap->PutPixel() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4473 return;
4474 }
4475
4476 80910 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4477
1/2
✓ Branch 0 taken 80910 times.
✗ Branch 1 not taken.
80910 if ( refbmp == NULL ) return;
4478
4479
2/4
✓ Branch 0 taken 80910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80910 times.
✗ Branch 3 not taken.
80910 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4480
4481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80910 times.
80910 if(sdci[7]!=0) //rotation
4482 {
4483 int32_t xy[2];
4484 int32_t rx=sdci[5]/10000;
4485 int32_t ry=sdci[6]/10000;
4486 fixed ra1=itofix(sdci[7]%10000)/10000;
4487 fixed ra2=itofix(sdci[7]/10000);
4488 fixed ra=ra1+ra2;
4489
4490 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4491 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4492 x1=xy[0];
4493 y1=xy[1];
4494 }
4495
4496 80910 putpixel(refbmp, x1+xoffset, y1+yoffset, color);
4497 80910 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4498 80910 }
4499
4500
4501 59428 void bmp_do_drawtiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4502 {
4503 //sdci[1]=layer
4504 //sdci[2]=x
4505 //sdci[3]=y
4506 //sdci[4]=tile
4507 //sdci[5]=tile width
4508 //sdci[6]=tile height
4509 //sdci[7]=color (cset)
4510 //sdci[8]=scale x
4511 //sdci[9]=scale y
4512 //sdci[10]=rotation anchor x
4513 //sdci[11]=rotation anchor y
4514 //sdci[12]=rotation angle
4515 //sdci[13]=flip
4516 //sdci[14]=transparency
4517 //sdci[15]=opacity
4518 //sdci[17] Bitmap Pointer
4519
4520 59428 int32_t w = sdci[5]/10000;
4521 59428 int32_t h = sdci[6]/10000;
4522
4523
4/8
✓ Branch 0 taken 59428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59428 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 59428 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 59428 times.
59428 if(w < 1 || h < 1 || h > 20 || w > 20)
4524 {
4525 return;
4526 }
4527
4528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59428 times.
59428 if ( sdci[17] <= 0 )
4529 {
4530 Z_scripterrlog("bitmap->DrawTile() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4531 return;
4532 }
4533
4534 59428 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59428 times.
59428 if ( refbmp == NULL ) return;
4536
4537 59428 int32_t xscale=sdci[8]/10000;
4538 59428 int32_t yscale=sdci[9]/10000;
4539 59428 int32_t rx = sdci[10]/10000;
4540 59428 int32_t ry = sdci[11]/10000;
4541 59428 float rotation=sdci[12]/10000;
4542 59428 int32_t flip=(sdci[13]/10000)&3;
4543 59428 bool transparency=sdci[14]!=0;
4544 59428 int32_t opacity=sdci[15]/10000;
4545 59428 int32_t color=sdci[7]/10000;
4546
4547 59428 int32_t x1=sdci[2]/10000;
4548 59428 int32_t y1=sdci[3]/10000;
4549
4550
4551 //don't scale if it's not safe to do so
4552 59428 bool canscale = true;
4553
4554
2/4
✓ Branch 0 taken 59428 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 59428 times.
59428 if(xscale==0||yscale==0)
4555 {
4556 return;
4557 }
4558
4559
3/4
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 58522 times.
✓ Branch 2 taken 906 times.
✗ Branch 3 not taken.
59428 if(xscale<0||yscale<0)
4560 58522 canscale = false; //default size
4561
4562
2/4
✓ Branch 0 taken 59428 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 59428 times.
59428 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4563
4564
4/4
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 58522 times.
✓ Branch 2 taken 4608 times.
✓ Branch 3 taken 53914 times.
59428 if((xscale>0 && yscale>0) || rotation) //scaled or rotated
4565 {
4566 5514 BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16);
4567
4568
1/2
✓ Branch 0 taken 5514 times.
✗ Branch 1 not taken.
5514 if(transparency) //transparency
4569 {
4570 5514 TileHelper::OverTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip);
4571 5514 }
4572 else //no transparency
4573 {
4574 TileHelper::OldPutTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip);
4575 }
4576
4577
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 906 times.
5514 if(rotation != 0)
4578 {
4579 //low negative values indicate no anchor-point rotation
4580
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4608 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4608 if(rx>-777||ry>-777)
4581 {
4582 int32_t xy[2];
4583 4608 fixed ra1=itofix(sdci[12]%10000)/10000;
4584 4608 fixed ra2=itofix(sdci[12]/10000);
4585 4608 fixed ra=ra1+ra2;
4586 4608 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4587 4608 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4588 4608 x1=xy[0];
4589 4608 y1=xy[1];
4590 4608 }
4591
4592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4608 times.
4608 if(canscale) //scale first
4593 {
4594 //damnit all, .. fixme.
4595 BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
4596 clear_bitmap(tempbit);
4597
4598 stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
4599
4600 if(opacity < 128)
4601 {
4602 clear_bitmap(prim_bmp);
4603 rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
4604 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
4605 }
4606 else
4607 {
4608 rotate_sprite(refbmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
4609 }
4610
4611 destroy_bitmap(tempbit);
4612 }
4613 else //no scale
4614 {
4615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4608 times.
4608 if(opacity < 128)
4616 {
4617 clear_bitmap(prim_bmp);
4618 rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
4619 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4620 }
4621 else
4622 {
4623 4608 rotate_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
4624 }
4625 }
4626 4608 }
4627 else //scale only
4628 {
4629
1/2
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
906 if(canscale)
4630 {
4631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(opacity<128)
4632 {
4633 clear_bitmap(prim_bmp);
4634 stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
4635 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4636 }
4637 else
4638 {
4639 906 stretch_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
4640 }
4641 906 }
4642 else //error -do not scale
4643 {
4644 if(opacity<128)
4645 {
4646 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4647 }
4648 else
4649 {
4650 draw_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset);
4651 }
4652 }
4653 }
4654
4655 5514 script_drawing_commands.ReleaseSubBitmap(pbitty);
4656
4657 5514 }
4658 else // no scale or rotation
4659 {
4660
2/2
✓ Branch 0 taken 45760 times.
✓ Branch 1 taken 8154 times.
53914 if(transparency)
4661 {
4662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45760 times.
45760 if(opacity<=127)
4663 TileHelper::OverTileTranslucent(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity);
4664 else
4665 45760 TileHelper::OverTile(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip);
4666 45760 }
4667 else
4668 {
4669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8154 times.
8154 if(opacity<=127)
4670 TileHelper::PutTileTranslucent(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity);
4671 else
4672 8154 TileHelper::OldPutTile(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip);
4673 }
4674 }
4675 59428 }
4676
4677 void bmp_do_drawtilecloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4678 {
4679 //sdci[1]=layer
4680 //sdci[2]=x
4681 //sdci[3]=y
4682 //sdci[4]=tile
4683 //sdci[5]=tile width
4684 //sdci[6]=tile height
4685 //sdci[7]=flip
4686 //sdci[17] Bitmap Pointer
4687
4688 int32_t w = sdci[5]/10000;
4689 int32_t h = sdci[6]/10000;
4690
4691 if(w < 1 || h < 1 || h > 20 || w > 20)
4692 {
4693 return;
4694 }
4695
4696 if ( sdci[17] <= 0 )
4697 {
4698 Z_scripterrlog("bitmap->DrawTileCloaked() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4699 return;
4700 }
4701
4702 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4703 if ( refbmp == NULL ) return;
4704
4705 int32_t flip=(sdci[7]/10000)&3;
4706
4707 int32_t x1=sdci[2]/10000;
4708 int32_t y1=sdci[3]/10000;
4709
4710 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4711
4712 TileHelper::OverTileCloaked(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, flip);
4713 }
4714
4715
4716 824 void bmp_do_drawcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4717 {
4718 //sdci[1]=layer
4719 //sdci[2]=x
4720 //sdci[3]=y
4721 //sdci[4]=combo
4722 //sdci[5]=tile width
4723 //sdci[6]=tile height
4724 //sdci[7]=color (cset)
4725 //sdci[8]=scale x
4726 //sdci[9]=scale y
4727 //sdci[10]=rotation anchor x
4728 //sdci[11]=rotation anchor y
4729 //sdci[12]=rotation angle
4730 //sdci[13]=frame
4731 //sdci[14]=flip
4732 //sdci[15]=transparency
4733 //sdci[16]=opacity
4734 //sdci[17] Bitmap Pointer
4735 824 int32_t w = sdci[5]/10000;
4736 824 int32_t h = sdci[6]/10000;
4737
4738
4/8
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 824 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 824 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 824 times.
824 if(w<1||h<1||h>20||w>20)
4739 {
4740 return;
4741 }
4742
4743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 824 times.
824 if ( sdci[17] <= 0 )
4744 {
4745 Z_scripterrlog("bitmap->DrawCombo() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4746 return;
4747 }
4748
4749 824 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4750
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if ( refbmp == NULL ) return;
4751 824 int32_t cmb = (sdci[4]/10000);
4752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 824 times.
824 if((unsigned)cmb >= MAXCOMBOS)
4753 {
4754 Z_scripterrlog("DrawCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb);
4755 return;
4756 }
4757
4758 824 int32_t xscale=sdci[8]/10000;
4759 824 int32_t yscale=sdci[9]/10000;
4760 824 int32_t rx = sdci[10]/10000; //these work now
4761 824 int32_t ry = sdci[11]/10000; //these work now
4762 824 float rotation=sdci[12]/10000;
4763
4764 824 bool transparency=sdci[15]!=0;
4765 824 int32_t opacity=sdci[16]/10000;
4766 824 int32_t color=sdci[7]/10000;
4767 824 int32_t x1=sdci[2]/10000;
4768 824 int32_t y1=sdci[3]/10000;
4769
4770 824 const newcombo & c = combobuf[cmb];
4771 824 int32_t tiletodraw = combo_tile(c, x1, y1);
4772 824 int32_t flip = ((sdci[14]/10000) & 3) ^ c.flip;
4773 824 int32_t skiprows=c.skipanimy;
4774
4775
4776 //don't scale if it's not safe to do so
4777 824 bool canscale = true;
4778
4779
2/4
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 824 times.
824 if(xscale==0||yscale==0)
4780 {
4781 return;
4782 }
4783
4784
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 824 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
824 if(xscale<0||yscale<0)
4785 824 canscale = false; //default size
4786
4787
2/4
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 824 times.
824 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4788
4789
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 824 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 824 times.
824 if((xscale>0 && yscale>0) || rotation) //scaled or rotated
4790 {
4791 BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16); //-pbitty in the hisouse. :D
4792
4793 if(transparency)
4794 {
4795 TileHelper::OverTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
4796 }
4797 else //no transparency
4798 {
4799 TileHelper::OldPutTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
4800 }
4801
4802 if(rotation != 0) // rotate
4803 {
4804 //fixed point sucks ;0
4805 if(rx>-777||ry>-777) //set the rotation anchor and rotate around that
4806 {
4807 int32_t xy[2];
4808 fixed ra1=itofix(sdci[12]%10000)/10000;
4809 fixed ra2=itofix(sdci[12]/10000);
4810 fixed ra=ra1+ra2;
4811 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4812 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4813 x1=xy[0];
4814 y1=xy[1];
4815 }
4816
4817 if(canscale) //scale first
4818 {
4819 BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
4820 clear_bitmap(tempbit);
4821
4822 stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
4823
4824 if(opacity < 128)
4825 {
4826 clear_bitmap(prim_bmp);
4827 rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
4828 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4829 }
4830 else
4831 {
4832 rotate_sprite(refbmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
4833 }
4834
4835 destroy_bitmap(tempbit);
4836 }
4837 else //no scale
4838 {
4839 if(opacity < 128)
4840 {
4841 clear_bitmap(prim_bmp);
4842 rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
4843 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4844 }
4845 else
4846 {
4847 rotate_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
4848 }
4849 }
4850 }
4851 else //scale only
4852 {
4853 if(canscale)
4854 {
4855 if(opacity<128)
4856 {
4857 clear_bitmap(prim_bmp);
4858 stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
4859 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4860 }
4861 else
4862 {
4863 stretch_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
4864 }
4865 }
4866 else //error -do not scale
4867 {
4868 if(opacity<128)
4869 {
4870 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4871 }
4872 else
4873 {
4874 draw_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset);
4875 }
4876 }
4877 }
4878
4879 script_drawing_commands.ReleaseSubBitmap(pbitty); //rap sucks
4880 }
4881 else // no scale or rotation
4882 {
4883
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
824 if(transparency)
4884 {
4885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 824 times.
824 if(opacity<=127)
4886 TileHelper::OverTileTranslucent(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
4887 else
4888 824 TileHelper::OverTile(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
4889 824 }
4890 else
4891 {
4892 if(opacity<=127)
4893 TileHelper::PutTileTranslucent(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
4894 else
4895 TileHelper::OldPutTile(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
4896 }
4897 }
4898 824 }
4899
4900
4901 void bmp_do_drawcombocloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4902 {
4903 //sdci[1]=layer
4904 //sdci[2]=x
4905 //sdci[3]=y
4906 //sdci[4]=combo
4907 //sdci[5]=tile width
4908 //sdci[6]=tile height
4909 //sdci[7]=flip
4910 //sdci[17] Bitmap Pointer
4911
4912 int32_t w = sdci[5]/10000;
4913 int32_t h = sdci[6]/10000;
4914
4915 if(w<1||h<1||h>20||w>20)
4916 {
4917 return;
4918 }
4919
4920 if ( sdci[17] <= 0 )
4921 {
4922 Z_scripterrlog("bitmap->DrawComboCloaked() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4923 return;
4924 }
4925
4926 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4927 if ( refbmp == NULL ) return;
4928 int32_t cmb = (sdci[4]/10000);
4929 if((unsigned)cmb >= MAXCOMBOS)
4930 {
4931 Z_scripterrlog("DrawComboCloaked() cannot draw combo '%d', as it is out of bounds.\n", cmb);
4932 return;
4933 }
4934
4935 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4936
4937 int32_t x1=sdci[2]/10000;
4938 int32_t y1=sdci[3]/10000;
4939
4940 const newcombo & c = combobuf[cmb];
4941 int32_t tiletodraw = combo_tile(c, x1, y1);
4942 int32_t flip = ((sdci[7]/10000) & 3) ^ c.flip;
4943 int32_t skiprows=c.skipanimy;
4944
4945 TileHelper::OverTileCloaked(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, flip, skiprows);
4946 }
4947
4948
4949 167316 void bmp_do_fasttiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4950 {
4951 /* layer, x, y, tile, color opacity */
4952 //sdci[17] Bitmap Pointer
4953
4954 167316 int32_t opacity = sdci[6]/10000;
4955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 167316 times.
167316 if ( sdci[17] <= 0 )
4956 {
4957 Z_scripterrlog("bitmap->FastTile() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4958 return;
4959 }
4960 167316 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4961
1/2
✓ Branch 0 taken 167316 times.
✗ Branch 1 not taken.
167316 if ( refbmp == NULL ) return;
4962
4963
2/4
✓ Branch 0 taken 167316 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 167316 times.
✗ Branch 3 not taken.
167316 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4964
4965
2/2
✓ Branch 0 taken 11131 times.
✓ Branch 1 taken 156185 times.
167316 if(opacity < 128)
4966 11131 overtiletranslucent16(refbmp, sdci[4]/10000, xoffset+(sdci[2]/10000), yoffset+(sdci[3]/10000), sdci[5]/10000, 0, opacity);
4967 else
4968 156185 overtile16(refbmp, sdci[4]/10000, xoffset+(sdci[2]/10000), yoffset+(sdci[3]/10000), sdci[5]/10000, 0);
4969 167316 }
4970
4971 void do_bmpwritetile(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4972 {
4973 /* layer, x, y, tile, is8bit, mask */
4974 //sdci[17] Bitmap Pointer
4975 if ( sdci[17] <= 0 )
4976 {
4977 Z_scripterrlog("bitmap->WriteTile() wanted to read from an invalid bitmap id: %d. Aborting.\n", sdci[17]);
4978 return;
4979 }
4980 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
4981 if ( refbmp == NULL ) return;
4982
4983 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
4984
4985 int32_t x = (sdci[2]/10000), y = (sdci[3]/10000), tl = (sdci[4]/10000);
4986 bool is8bit = sdci[5]!=0, mask = sdci[6]!=0;
4987
4988 write_tile(newtilebuf, refbmp, tl, x+xoffset, y+yoffset, is8bit, mask);
4989 }
4990
4991 void do_bmpdither(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4992 {
4993 /* layer, mask, color, ditherType, ditherArg */
4994 //sdci[2] Mask Bitmap Pointer
4995 //sdci[3] Color
4996 //sdci[17] Bitmap Pointer
4997 if ( sdci[17] <= 0 )
4998 {
4999 Z_scripterrlog("bitmap->Dither() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5000 return;
5001 }
5002 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
5003 if ( refbmp == NULL ) return;
5004 if ( sdci[2] <= 0 )
5005 {
5006 Z_scripterrlog("bitmap->Dither() wanted to read from an invalid bitmap id: %d. Aborting.\n", sdci[2]);
5007 return;
5008 }
5009 BITMAP *mask = FFCore.GetScriptBitmap(sdci[2]-10);
5010 if ( mask == NULL ) return;
5011
5012 int32_t dType = sdci[4] / 10000L;
5013 if(dType < 0 || dType >= dithMax)
5014 {
5015 Z_scripterrlog("bitmap->Dither() used an invalid dither type: %d. Aborting.\n", dType);
5016 return;
5017 }
5018
5019 ditherblit(refbmp, mask, byte(sdci[3]/10000L), dType, sdci[5]/10000L);
5020 }
5021
5022 6363 void do_bmpreplcol(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5023 {
5024 /* layer, shift, startcol, endcol */
5025 //sdci[2] NewCol
5026 //sdci[3] StartCol
5027 //sdci[4] EndCol
5028 //sdci[17] Bitmap Pointer
5029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6363 times.
6363 if ( sdci[17] <= 0 )
5030 {
5031 Z_scripterrlog("bitmap->ReplaceColors() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5032 return;
5033 }
5034 6363 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
5035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6363 times.
6363 if ( refbmp == NULL ) return;
5036 6363 replColor(refbmp, sdci[2]/10000L, sdci[3]/10000L, sdci[4]/10000L, false);
5037 6363 }
5038
5039 void do_bmpshiftcol(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5040 {
5041 /* layer, shift, startcol, endcol */
5042 //sdci[2] ShiftAmount
5043 //sdci[3] StartCol
5044 //sdci[4] EndCol
5045 //sdci[17] Bitmap Pointer
5046 if ( sdci[17] <= 0 )
5047 {
5048 Z_scripterrlog("bitmap->ShiftColors() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5049 return;
5050 }
5051 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
5052 if ( refbmp == NULL ) return;
5053 replColor(refbmp, sdci[2]/10000L, sdci[3]/10000L, sdci[4]/10000L, true);
5054 }
5055
5056 906 void do_bmpmaskdraw(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5057 {
5058 /* layer, mask, color */
5059 //sdci[2] Mask Bitmap Pointer
5060 //sdci[3] Color
5061 //sdci[4] start mask color
5062 //sdci[5] end mask color
5063 //sdci[17] Bitmap Pointer
5064 906 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
5065
1/2
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
906 if ( refbmp == NULL )
5066 {
5067 Z_scripterrlog("bitmap->MaskDraw() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5068 return;
5069 }
5070 906 BITMAP *mask = FFCore.GetScriptBitmap(sdci[2]-10);
5071
1/2
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
906 if ( mask == NULL )
5072 {
5073 Z_scripterrlog("bitmap->MaskDraw() wanted to read from an invalid bitmap id: %d. Aborting.\n", sdci[2]);
5074 return;
5075 }
5076 906 auto fillcol = sdci[3]/10000L;
5077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(unsigned(fillcol) > 0xFF) return; //invalid color, nothing to draw
5078 906 auto startcol = vbound(sdci[4]/10000L,0x00,0xFF);
5079 906 auto endcol = vbound(sdci[5]/10000L,0x00,0xFF);
5080 906 mask_colorfill(refbmp, mask, fillcol, startcol, endcol);
5081 906 }
5082
5083 void do_bmpmaskblit(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5084 {
5085 /* layer, mask, color */
5086 //sdci[2] Mask Bitmap Pointer
5087 //sdci[3] Pattern Bitmap
5088 //sdci[4] bool 'pattern repeats'
5089 //sdci[5] start mask color
5090 //sdci[6] end mask color
5091 //sdci[17] Bitmap Pointer
5092 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
5093 if ( refbmp == NULL )
5094 {
5095 Z_scripterrlog("bitmap->MaskDraw() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5096 return;
5097 }
5098 BITMAP *mask = FFCore.GetScriptBitmap(sdci[2]-10);
5099 if ( mask == NULL )
5100 {
5101 Z_scripterrlog("bitmap->MaskDraw() wanted to read from an invalid bitmap (mask) id: %d. Aborting.\n", sdci[2]);
5102 return;
5103 }
5104 BITMAP *pattern = FFCore.GetScriptBitmap(sdci[3]-10);
5105 if ( pattern == NULL )
5106 {
5107 Z_scripterrlog("bitmap->MaskDraw() wanted to read from an invalid bitmap (pattern) id: %d. Aborting.\n", sdci[3]);
5108 return;
5109 }
5110 bool repeats = sdci[4]!=0;
5111 auto startcol = vbound(sdci[5]/10000L,0x00,0xFF);
5112 auto endcol = vbound(sdci[6]/10000L,0x00,0xFF);
5113 mask_blit(refbmp, mask, pattern, repeats, startcol, endcol);
5114 }
5115
5116 784 void bmp_do_fastcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5117 {
5118 /* layer, x, y, tile, color opacity */
5119 //sdci[17] Bitmap Pointer
5120 784 int32_t opacity = sdci[6] / 10000;
5121 784 int32_t x1 = sdci[2] / 10000;
5122 784 int32_t y1 = sdci[3] / 10000;
5123 784 int32_t index = sdci[4]/10000;
5124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 784 times.
784 if ( sdci[17] <= 0 )
5125 {
5126 Z_scripterrlog("bitmap->FastCombo() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5127 return;
5128 }
5129 784 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
5130
1/2
✓ Branch 0 taken 784 times.
✗ Branch 1 not taken.
784 if ( refbmp == NULL ) return;
5131 784 int32_t cmb = (sdci[4]/10000);
5132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 784 times.
784 if((unsigned)cmb >= MAXCOMBOS)
5133 {
5134 Z_scripterrlog("FastCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb);
5135 return;
5136 }
5137
5138
2/4
✓ Branch 0 taken 784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 784 times.
✗ Branch 3 not taken.
784 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
5139
5140 //if( index >= MAXCOMBOS ) return; //bleh.
5141 /*
5142 const newcombo & c = combobuf[index];
5143
5144 if(opacity < 128)
5145 overtiletranslucent16(refbmp, combo_tile(c, x1, y1), xoffset+x1, yoffset+y1, sdci[5]/10000, (int32_t)c.flip, opacity);
5146 else
5147 overtile16(refbmp, combo_tile(c, x1, y1), xoffset+x1, yoffset+y1, sdci[5]/10000, (int32_t)c.flip);
5148 */
5149
5150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 784 times.
784 if(opacity < 128)
5151 {
5152 //void overcomboblocktranslucent(BITMAP *dest, int32_t x, int32_t y, int32_t cmbdat, int32_t cset, int32_t w, int32_t h, int32_t opacity)
5153 overcomboblocktranslucent(refbmp, xoffset+x1, yoffset+y1, cmb, sdci[5]/10000, 1, 1, 128);
5154
5155 }
5156 else
5157 {
5158 //overcomboblock(BITMAP *dest, int32_t x, int32_t y, int32_t cmbdat, int32_t cset, int32_t w, int32_t h)
5159 784 overcomboblock(refbmp, xoffset+x1, yoffset+y1, cmb, sdci[5]/10000, 1, 1);
5160 }
5161 784 }
5162
5163
5164
5165 void bmp_do_drawcharr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5166 {
5167 //sdci[17] Bitmap Pointer
5168 if ( sdci[17] <= 0 )
5169 {
5170 Z_scripterrlog("bitmap->DrawCharacter() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5171 return;
5172 }
5173 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
5174 if ( refbmp == NULL ) return;
5175
5176 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
5177
5178 //broken 2.50.2 and earlier drawcharacter()
5179 if ( get_qr(qr_BROKENCHARINTDRAWING) )
5180 {
5181 //sdci[1]=layer
5182 //sdci[2]=x
5183 //sdci[3]=y
5184 //sdci[4]=font
5185 //sdci[5]=color
5186 //sdci[6]=bg color
5187 //sdci[7]=strech x (width)
5188 //sdci[8]=stretch y (height)
5189 //sdci[9]=char
5190 //sdci[10]=opacity
5191 //sdci[17] Bitmap Pointer
5192
5193 int32_t x=sdci[2]/10000;
5194 int32_t y=sdci[3]/10000;
5195 int32_t font_index=sdci[4]/10000;
5196 int32_t color=sdci[5]/10000;
5197 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5198 int32_t w=sdci[7]/10000;
5199 int32_t h=sdci[8]/10000;
5200 char glyph=char(sdci[9]/10000);
5201 int32_t opacity=sdci[10]/10000;
5202
5203 //safe check
5204 if(bg_color < -1) bg_color = -1;
5205
5206 if(w>512) w=512; //w=vbound(w,0,512);
5207
5208 if(h>512) h=512; //h=vbound(h,0,512);
5209
5210 //undone
5211 if(w>0&&h>0)//stretch the character
5212 {
5213 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
5214
5215 if(opacity < 128)
5216 {
5217 if(w>128||h>128)
5218 {
5219 clear_bitmap(prim_bmp);
5220
5221 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5222 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
5223 draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset);
5224 }
5225 else //this is faster
5226 {
5227 BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h);
5228
5229 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5230 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
5231 draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset);
5232
5233 script_drawing_commands.ReleaseSubBitmap(pbmp2);
5234 }
5235 }
5236 else // no opacity
5237 {
5238 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5239 stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h);
5240 }
5241
5242 }
5243 else //no stretch
5244 {
5245 if(opacity < 128)
5246 {
5247 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
5248 clear_bitmap(pbmp);
5249
5250 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5251 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5252
5253 destroy_bitmap(pbmp);
5254 }
5255 else // no opacity
5256 {
5257 textprintf_ex(refbmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph);
5258 }
5259 }
5260 }
5261
5262 else //2.53.0 fixed version and later.
5263 {
5264
5265 //sdci[1]=layer
5266 //sdci[2]=x
5267 //sdci[3]=y
5268 //sdci[4]=font
5269 //sdci[5]=color
5270 //sdci[6]=bg color
5271 //sdci[7]=strech x (width)
5272 //sdci[8]=stretch y (height)
5273 //sdci[9]=char
5274 //sdci[10]=opacity
5275
5276 int32_t x=sdci[2]/10000;
5277 int32_t y=sdci[3]/10000;
5278 int32_t font_index=sdci[4]/10000;
5279 int32_t color=sdci[5]/10000;
5280 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5281 int32_t w=sdci[7]/10000;
5282 int32_t h=sdci[8]/10000;
5283 char glyph=char(sdci[9]/10000);
5284 int32_t opacity=sdci[10]/10000;
5285
5286 //safe check
5287 if(bg_color < -1) bg_color = -1;
5288
5289 if(w>512) w=512; //w=vbound(w,0,512);
5290
5291 if(h>512) h=512; //h=vbound(h,0,512);
5292
5293 //undone
5294 if(w>0&&h>0)//stretch the character
5295 {
5296 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
5297
5298 if(opacity < 128)
5299 {
5300 if(w>128||h>128)
5301 {
5302 clear_bitmap(prim_bmp);
5303
5304 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5305 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
5306 draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset);
5307 }
5308 else //this is faster
5309 {
5310 BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h);
5311
5312 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5313 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
5314 draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset);
5315
5316 script_drawing_commands.ReleaseSubBitmap(pbmp2);
5317 }
5318 }
5319 else // no opacity
5320 {
5321 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5322 stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h);
5323 }
5324
5325 }
5326 else //no stretch
5327 {
5328 if(opacity < 128)
5329 {
5330 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
5331 clear_bitmap(pbmp);
5332
5333 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5334 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5335
5336 destroy_bitmap(pbmp);
5337 }
5338 else // no opacity
5339 {
5340 textprintf_ex(refbmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph);
5341 }
5342 }
5343
5344 }
5345
5346 }
5347
5348
5349 void bmp_do_drawintr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5350 {
5351 if ( sdci[17] <= 0 )
5352 {
5353 Z_scripterrlog("bitmap->DrawInteger() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5354 return;
5355 }
5356 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
5357 if ( refbmp == NULL ) return;
5358
5359 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
5360
5361 //broken 2.50.2 and earlier drawinteger()
5362 if ( get_qr(qr_BROKENCHARINTDRAWING) )
5363 {
5364 //sdci[1]=layer
5365 //sdci[2]=x
5366 //sdci[3]=y
5367 //sdci[4]=font
5368 //sdci[5]=color
5369 //sdci[6]=bg color
5370 //sdci[7]=strech x (width)
5371 //sdci[8]=stretch y (height)
5372 //sdci[9]=integer
5373 //sdci[10]=num decimal places
5374 //sdci[11]=opacity
5375 //sdci[17] Bitmap Pointer
5376
5377 int32_t x=sdci[2]/10000;
5378 int32_t y=sdci[3]/10000;
5379 int32_t font_index=sdci[4]/10000;
5380 int32_t color=sdci[5]/10000;
5381 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5382 int32_t w=sdci[7]/10000;
5383 int32_t h=sdci[8]/10000;
5384 //float number=static_cast<float>(sdci[9])/10000.0f;
5385 int32_t decplace=sdci[10]/10000;
5386 int32_t opacity=sdci[11]/10000;
5387
5388 //safe check
5389 if(bg_color < -1) bg_color = -1;
5390
5391 if(w>512) w=512; //w=vbound(w,0,512);
5392
5393 if(h>512) h=512; //h=vbound(h,0,512);
5394
5395 char numbuf[15];
5396
5397 switch(decplace)
5398 {
5399 default:
5400 case 0:
5401 sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was
5402 break; //reducing the value by -1, so 8.000 printed as '7'. -Z
5403
5404 case 1:
5405 //sprintf(numbuf,"%.01f",number);
5406 sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower?
5407 break;
5408
5409 case 2:
5410 //sprintf(numbuf,"%.02f",number);
5411 sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f));
5412 break;
5413
5414 case 3:
5415 //sprintf(numbuf,"%.03f",number);
5416 sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f));
5417 break;
5418
5419 case 4:
5420 //sprintf(numbuf,"%.04f",number);
5421 sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f));
5422 break;
5423 }
5424
5425 if(w>0&&h>0)//stretch
5426 {
5427 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
5428
5429 if(opacity < 128)
5430 {
5431 if(w>128||h>128)
5432 {
5433 clear_bitmap(prim_bmp);
5434
5435 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5436 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
5437 draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset);
5438 }
5439 else
5440 {
5441 BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h);
5442 clear_bitmap(pbmp2);
5443
5444 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5445 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
5446 draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset);
5447
5448 destroy_bitmap(pbmp2);
5449 }
5450 }
5451 else // no opacity
5452 {
5453 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5454 stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h);
5455 }
5456
5457 }
5458 else //no stretch
5459 {
5460 if(opacity < 128)
5461 {
5462 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
5463 clear_bitmap(pbmp);
5464
5465 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5466 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5467
5468 destroy_bitmap(pbmp);
5469 }
5470 else // no opacity
5471 {
5472 textout_ex(refbmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color);
5473 }
5474 }
5475
5476 }
5477
5478 else //2.53.0 fixed version and later.
5479 {
5480 //sdci[1]=layer
5481 //sdci[2]=x
5482 //sdci[3]=y
5483 //sdci[4]=font
5484 //sdci[5]=color
5485 //sdci[6]=bg color
5486 //sdci[7]=strech x (width)
5487 //sdci[8]=stretch y (height)
5488 //sdci[9]=integer
5489 //sdci[10]=num decimal places
5490 //sdci[11]=opacity
5491
5492 int32_t x=sdci[2]/10000;
5493 int32_t y=sdci[3]/10000;
5494 int32_t font_index=sdci[4]/10000;
5495 int32_t color=sdci[5]/10000;
5496 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5497 int32_t w=sdci[7]/10000;
5498 int32_t h=sdci[8]/10000;
5499 //float number=static_cast<float>(sdci[9])/10000.0f;
5500 //int32_t numberint = sdci[9]/10000;
5501 int32_t decplace=sdci[10]/10000;
5502 int32_t opacity=sdci[11]/10000;
5503
5504 //safe check
5505 if(bg_color < -1) bg_color = -1;
5506
5507 if(w>512) w=512; //w=vbound(w,0,512);
5508
5509 if(h>512) h=512; //h=vbound(h,0,512);
5510
5511 char numbuf[15];
5512
5513 switch(decplace)
5514 {
5515 default:
5516 case 0:
5517 sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was
5518 break; //reducing the value by -1, so 8.000 printed as '7'. -Z
5519
5520 case 1:
5521 //sprintf(numbuf,"%.01f",number);
5522 sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower?
5523 break;
5524
5525 case 2:
5526 //sprintf(numbuf,"%.02f",number);
5527 sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f));
5528 break;
5529
5530 case 3:
5531 //sprintf(numbuf,"%.03f",number);
5532 sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f));
5533 break;
5534
5535 case 4:
5536 //sprintf(numbuf,"%.04f",number);
5537 sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f));
5538 break;
5539 }
5540
5541 //FONT* font=get_zc_font(sdci[4]/10000);
5542
5543 if(w>0&&h>0)//stretch
5544 {
5545 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(get_zc_font(font_index), numbuf)+1, text_height(get_zc_font(font_index)));
5546 clear_bitmap(pbmp);
5547 //script_drawing_commands.GetSmallTextureBitmap(1,1);
5548
5549 if(opacity < 128)
5550 {
5551 if(w>128||h>128)
5552 {
5553 clear_bitmap(prim_bmp);
5554
5555 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5556 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
5557 draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset);
5558 }
5559 else
5560 {
5561 BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h);
5562 clear_bitmap(pbmp2);
5563
5564 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5565 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
5566 draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset);
5567
5568 destroy_bitmap(pbmp2);
5569 }
5570 }
5571 else // no opacity
5572 {
5573 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5574 stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h);
5575 }
5576
5577 }
5578 else //no stretch
5579 {
5580 if(opacity < 128)
5581 {
5582 FONT* font = get_zc_font(font_index);
5583 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(font, numbuf), text_height(font));
5584 clear_bitmap(pbmp);
5585
5586 textout_ex(pbmp, font, numbuf, 0, 0, color, bg_color);
5587 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5588
5589 destroy_bitmap(pbmp);
5590 }
5591 else // no opacity
5592 {
5593 textout_ex(refbmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color);
5594 }
5595 }
5596 }
5597 }
5598
5599
5600 void bmp_do_drawstringr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5601 {
5602 //sdci[1]=layer
5603 //sdci[2]=x
5604 //sdci[3]=y
5605 //sdci[4]=font
5606 //sdci[5]=color
5607 //sdci[6]=bg color
5608 //sdci[7]=format_option
5609 //sdci[8]=string
5610 //sdci[9]=opacity
5611 //sdci[17] Bitmap Pointer
5612 if ( sdci[17] <= 0 )
5613 {
5614 Z_scripterrlog("bitmap->DrawString() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5615 return;
5616 }
5617
5618 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
5619 if ( refbmp == NULL ) return;
5620
5621 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
5622
5623 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
5624
5625 if(!str)
5626 {
5627 al_trace("String pointer is null! Internal error. \n");
5628 return;
5629 }
5630
5631 int32_t x=sdci[2]/10000;
5632 int32_t y=sdci[3]/10000;
5633 FONT* font=get_zc_font(sdci[4]/10000);
5634 int32_t color=sdci[5]/10000;
5635 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5636 int32_t format_type=sdci[7]/10000;
5637 int32_t opacity=sdci[9]/10000;
5638 //sdci[8] not needed :)
5639
5640 //safe check
5641 if(bg_color < -1) bg_color = -1;
5642
5643 if(opacity < 128)
5644 {
5645 int32_t width=zc_min(text_length(font, str->c_str()), 512);
5646 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font));
5647 clear_bitmap(pbmp);
5648 textout_ex(pbmp, font, str->c_str(), 0, 0, color, bg_color);
5649 if(format_type == 2) // right-sided text
5650 x-=width;
5651 else if(format_type == 1) // centered text
5652 x-=width/2;
5653 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5654 destroy_bitmap(pbmp);
5655 }
5656 else // no opacity
5657 {
5658 if(format_type == 2) // right-sided text
5659 {
5660 textout_right_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
5661 }
5662 else if(format_type == 1) // centered text
5663 {
5664 textout_centre_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
5665 }
5666 else // standard left-sided text
5667 {
5668 textout_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
5669 }
5670 }
5671 }
5672
5673 45504 void bmp_do_drawstringr2(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5674 {
5675 //sdci[1]=layer
5676 //sdci[2]=x
5677 //sdci[3]=y
5678 //sdci[4]=font
5679 //sdci[5]=color
5680 //sdci[6]=bg color
5681 //sdci[7]=format_option
5682 //sdci[8]=string
5683 //sdci[9]=opacity
5684 //sdci[10]=shadowtype
5685 //sdci[11]=shadow_color
5686 //sdci[17] Bitmap Pointer
5687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45504 times.
45504 if ( sdci[17] <= 0 )
5688 {
5689 Z_scripterrlog("bitmap->DrawString() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5690 return;
5691 }
5692
5693 45504 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
5694
1/2
✓ Branch 0 taken 45504 times.
✗ Branch 1 not taken.
45504 if ( refbmp == NULL ) return;
5695
5696
2/4
✓ Branch 0 taken 45504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 45504 times.
45504 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
5697
5698 45504 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
5699
5700
1/2
✓ Branch 0 taken 45504 times.
✗ Branch 1 not taken.
45504 if(!str)
5701 {
5702 al_trace("String pointer is null! Internal error. \n");
5703 return;
5704 }
5705
5706 45504 int32_t x=sdci[2]/10000;
5707 45504 int32_t y=sdci[3]/10000;
5708 45504 FONT* font=get_zc_font(sdci[4]/10000);
5709 45504 int32_t color=sdci[5]/10000;
5710 45504 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5711 45504 int32_t format_type=sdci[7]/10000;
5712 45504 int32_t opacity=sdci[9]/10000;
5713 45504 int32_t textstyle = sdci[10]/10000;
5714 45504 int32_t shadow_color = sdci[11]/10000;
5715 //sdci[8] not needed :)
5716
5717 //safe check
5718
1/2
✓ Branch 0 taken 45504 times.
✗ Branch 1 not taken.
45504 if(bg_color < -1) bg_color = -1;
5719
5720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45504 times.
45504 if(opacity < 128)
5721 {
5722 int32_t width=zc_min(text_length(font, str->c_str()), 512);
5723 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font));
5724 clear_bitmap(pbmp);
5725 textout_styled_aligned_ex(pbmp, font, str->c_str(), 0, 0, textstyle, sstaLEFT, color, shadow_color, bg_color);
5726 if(format_type == 2) // right-sided text
5727 x-=width;
5728 else if(format_type == 1) // centered text
5729 x-=width/2;
5730 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5731 destroy_bitmap(pbmp);
5732 }
5733 else // no opacity
5734 {
5735 45504 textout_styled_aligned_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, textstyle, format_type, color, shadow_color, bg_color);
5736 }
5737 45504 }
5738
5739 26369 void bmp_do_clearr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5740 {
5741 //sdci[1]=layer
5742 //sdci[17] Bitmap Pointer
5743 //Z_scripterrlog("bitmap->Clear() pointer is: %d\n", sdci[17]);
5744
1/2
✓ Branch 0 taken 26369 times.
✗ Branch 1 not taken.
26369 if ( sdci[17] <= 0 )
5745 {
5746 Z_scripterrlog("bitmap->Clear() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5747 return;
5748 }
5749 26369 int32_t bitid = sdci[17] - 10;
5750
1/2
✓ Branch 0 taken 26369 times.
✗ Branch 1 not taken.
26369 if ( scb.script_created_bitmaps[bitid].u_bmp )
5751 26369 clear_bitmap(scb.script_created_bitmaps[bitid].u_bmp);
5752 26369 }
5753
5754 2790 void bmp_do_clearcolorr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5755 {
5756 //sdci[1]=layer
5757 //sdci[2]=color
5758 //sdci[17] Bitmap Pointer
5759 2790 int32_t pal_color = sdci[2]/10000;
5760
1/2
✓ Branch 0 taken 2790 times.
✗ Branch 1 not taken.
2790 if ( sdci[17] <= 0 )
5761 {
5762 Z_scripterrlog("bitmap->ClearToColor() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5763 return;
5764 }
5765 2790 int32_t bitid = sdci[17] - 10;
5766
1/2
✓ Branch 0 taken 2790 times.
✗ Branch 1 not taken.
2790 if ( scb.script_created_bitmaps[bitid].u_bmp )
5767 2790 clear_to_color(scb.script_created_bitmaps[bitid].u_bmp, pal_color);
5768 2790 }
5769
5770
5771 34653 void bmp_do_regenr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5772 {
5773 //sdci[1]=layer
5774 34653 int32_t h = sdci[3]/10000;
5775 34653 int32_t w = sdci[2]/10000;
5776
1/2
✓ Branch 0 taken 34653 times.
✗ Branch 1 not taken.
34653 if ( get_qr(qr_OLDCREATEBITMAP_ARGS) )
5777 {
5778 //flip height and width
5779 h = h ^ w;
5780 w = h ^ w;
5781 h = h ^ w;
5782 }
5783 //sdci[17] Bitmap Pointer
5784 //Z_scripterrlog("bitmap->Create() pointer is: %d\n", sdci[17]);
5785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34653 times.
34653 if ( sdci[17] <= 0 )
5786 {
5787 Z_scripterrlog("bitmap->Create() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5788 return;
5789 }
5790 34653 int32_t bitid = sdci[17] - 10;
5791
2/2
✓ Branch 0 taken 34528 times.
✓ Branch 1 taken 125 times.
34653 if ( scb.script_created_bitmaps[bitid].u_bmp )
5792 34528 destroy_bitmap(scb.script_created_bitmaps[bitid].u_bmp);
5793 34653 scb.script_created_bitmaps[bitid].u_bmp = create_bitmap_ex(8,w,h);
5794
5795 34653 scb.script_created_bitmaps[bitid].width = w;
5796 34653 scb.script_created_bitmaps[bitid].height = h;
5797
5798
5799
5800 34653 }
5801
5802 void bmp_do_readr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5803 {
5804 //sdci[1]=layer
5805 //sdci[2]=filename
5806 //sdci[3]=y
5807 //sdci[4]=font
5808 //sdci[5]=color
5809 //sdci[6]=bg color
5810 //sdci[7]=format_option
5811 //sdci[8]=string
5812 //sdci[9]=opacity
5813 //sdci[17] Bitmap Pointer
5814 //Z_scripterrlog("bitmap->Read() pointer is: %d\n", sdci[17]);
5815 if ( sdci[17] <= 0 )
5816 {
5817 Z_scripterrlog("bitmap->Read() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5818 return;
5819 }
5820 int32_t bitid = sdci[17] - 10;
5821 scb.script_created_bitmaps[bitid].destroy();
5822
5823 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
5824
5825 //char *cptr = new char[str->size()+1]; // +1 to account for \0 byte
5826 // std::strncpy(cptr, str->c_str(), str->size());
5827 // Z_scripterrlog("The following should be the filename string:\n");
5828 //Z_scripterrlog(" %s\n", cptr);
5829
5830 if(!str)
5831 {
5832 al_trace("String pointer is null! Internal error. \n");
5833 return;
5834 }
5835
5836 // Z_scripterrlog("Trying to read filename %s\n", cptr);
5837 PALETTE tempPal;
5838 get_palette(tempPal);
5839 if ( checkPath(str->c_str(), false) )
5840 {
5841 scb.script_created_bitmaps[bitid].u_bmp = load_bitmap(str->c_str(), tempPal);
5842 scb.script_created_bitmaps[bitid].width = scb.script_created_bitmaps[bitid].u_bmp->w;
5843 scb.script_created_bitmaps[bitid].height = scb.script_created_bitmaps[bitid].u_bmp->h;
5844 if ( !scb.script_created_bitmaps[bitid].u_bmp )
5845 {
5846 Z_scripterrlog("Failed to load image file %s.\nMaking a blank bitmap on the pointer.\n", str->c_str());
5847 //scb.script_created_bitmaps[bitid].u_bmp = create_bitmap_ex(8,256,176);
5848 //clear_bitmap(scb.script_created_bitmaps[bitid].u_bmp);
5849 }
5850 else
5851 {
5852 zprint("Read image file %s\n",str->c_str());
5853 }
5854 }
5855 else
5856 {
5857 Z_scripterrlog("Failed to load image file: %s. File not found. Creating a blank bitmap on the pointer.\n", str->c_str());
5858 scb.script_created_bitmaps[bitid].u_bmp = create_bitmap_ex(8,256,176);
5859 clear_bitmap(scb.script_created_bitmaps[bitid].u_bmp);
5860 }
5861 }
5862
5863
5864
5865 void bmp_do_writer(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5866 {
5867 //sdci[1]=layer
5868 //sdci[2]=filename
5869 //sdci[3]=y
5870 //sdci[4]=font
5871 //sdci[5]=color
5872 //sdci[6]=bg color
5873 //sdci[7]=format_option
5874 //sdci[8]=string
5875 //sdci[9]=opacity
5876 //sdci[17] Bitmap Pointer
5877 //Z_scripterrlog("bitmap->Write() pointer is: %d\n", sdci[17]);
5878
5879 if ( sdci[17] <= 0 )
5880 {
5881 Z_scripterrlog("bitmap->Write() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5882 return;
5883 }
5884 int32_t bitid = sdci[17] - 10;
5885
5886 if ( !scb.script_created_bitmaps[bitid].u_bmp )
5887 {
5888 Z_scripterrlog("Tried to write from an invalid bitmap pointer %d. Aborting. \n", sdci[17]);
5889 return;
5890 }
5891
5892 bool overwrite = (sdci[3] != 0);
5893 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
5894
5895 if(!str)
5896 {
5897 al_trace("String pointer is null! Internal error. \n");
5898 return;
5899 }
5900
5901 //char *cptr = new char[str->size()+1]; // +1 to account for \0 byte
5902 //std::strncpy(cptr, str->c_str(), str->size());
5903 //Z_scripterrlog("bitmap->Write extension matches ? : %s\n!", (FFCore.checkExtension(str->c_str(), ".png")) ? "true" : "false");
5904 //Z_scripterrlog("Trying to write filename %s\n", cptr);
5905 if
5906 (
5907 ( (FFCore.checkExtension(*str, "")) ) ||
5908 ( !(FFCore.checkExtension(*str, ".png")) && !(FFCore.checkExtension(*str, ".gif")) && !(FFCore.checkExtension(*str, ".bmp"))
5909 && !(FFCore.checkExtension(*str, ".pcx")) && !(FFCore.checkExtension(*str, ".tga")) )
5910 )
5911 {
5912 Z_scripterrlog("No extension, or invalid extension provided for writing bitmap file %s. Could not write the file.\nValid types are .png, .gif, .pcx, .tgx, and .bmp. Aborting.\n",str->c_str());
5913 }
5914 else if ( overwrite || (!checkPath(str->c_str(), false)) )
5915 {
5916 if(create_path(str->c_str()))
5917 {
5918 save_bitmap(str->c_str(), scb.script_created_bitmaps[bitid].u_bmp, RAMpal);
5919 if(checkPath(str->c_str(), false))
5920 {
5921 zprint("Wrote image file %s\n",str->c_str());
5922 }
5923 else
5924 {
5925 Z_scripterrlog("Failed to create file '%s'\n",str->c_str());
5926 }
5927 }
5928 else
5929 {
5930 Z_scripterrlog("Cannot write file '%s' because the directory does not exist, and could not be created.\n", str->c_str());
5931 }
5932 }
5933 else Z_scripterrlog("Cannot write file '%s' because the file already exists in the specified path.\n", str->c_str());
5934 }
5935
5936
5937 void bmp_do_drawquadr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5938 {
5939 //sdci[1]=layer
5940 //sdci[2]=x1
5941 //sdci[3]=y1
5942 //sdci[4]=x2
5943 //sdci[5]=y2
5944 //sdci[6]=x3
5945 //sdci[7]=y3
5946 //sdci[8]=x4
5947 //sdci[9]=y4
5948 //sdci[10]=width
5949 //sdci[11]=height
5950 //sdci[12]=cset
5951 //sdci[13]=flip
5952 //sdci[14]=tile/combo
5953 //sdci[15]=polytype
5954 //sdci[16] = other bitmap as texture
5955 //sdci[17] Bitmap Pointer
5956 Z_scripterrlog("bitmap quad pointer: %d\n", sdci[17]);
5957 if ( sdci[17] <= 0 )
5958 {
5959 Z_scripterrlog("bitmap->Quad() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
5960 return;
5961 }
5962 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
5963
5964 if ( !refbmp ) return;
5965
5966 int32_t x1 = sdci[2]/10000;
5967 int32_t y1 = sdci[3]/10000;
5968 int32_t x2 = sdci[4]/10000;
5969 int32_t y2 = sdci[5]/10000;
5970 int32_t x3 = sdci[6]/10000;
5971 int32_t y3 = sdci[7]/10000;
5972 int32_t x4 = sdci[8]/10000;
5973 int32_t y4 = sdci[9]/10000;
5974 int32_t w = sdci[10]/10000;
5975 int32_t h = sdci[11]/10000;
5976 int32_t color = sdci[12]/10000;
5977 int32_t flip=(sdci[13]/10000)&3;
5978 int32_t tile = sdci[14]/10000;
5979 int32_t polytype = sdci[15]/10000;
5980 int32_t quad_render_source = sdci[16]-10;
5981 //Z_scripterrlog("bitmap->Quad() render source is: %d\n", quad_render_source);
5982
5983 bool tex_is_bitmap = ( sdci[16] != 0 );
5984
5985 BITMAP *bmptexture=NULL;
5986 BITMAP *tex=NULL;
5987 polytype = vbound(polytype, 0, 14);
5988
5989 int32_t col[4];
5990 col[0]=col[1]=col[2]=col[3]=color;
5991 bool mustDestroyBmp = false;
5992
5993 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
5994
5995 if ( tex_is_bitmap )
5996 {
5997 bmptexture = FFCore.GetScriptBitmap(quad_render_source);
5998 if ( !bmptexture )
5999 {
6000 Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Triangle3()");
6001 tex_is_bitmap = 0;
6002 }
6003 }
6004
6005 if ( tex_is_bitmap )
6006 {
6007
6008 if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
6009 if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
6010 if ( !isPowerOfTwo(w) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", w);
6011 if ( !isPowerOfTwo(h) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", h);
6012
6013 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
6014 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(h), col[1] };
6015 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(w), static_cast<float>(h), col[2] };
6016 V3D_f V4 = { static_cast<float>(x4+xoffset), static_cast<float>(y4+yoffset), 0, static_cast<float>(w), 0, col[3] };
6017
6018 quad3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3, &V4);
6019 }
6020 else
6021 {
6022 tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
6023 if(!tex)
6024 {
6025 //Z_scripterrlog("Bitmap->Quad() found an invalid texture bitmap.\n");
6026 mustDestroyBmp = true;
6027 tex = create_bitmap_ex(8, w*16, h*16);
6028 clear_bitmap(tex);
6029 }
6030
6031 if(tile > 0) // TILE
6032 {
6033 TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip);
6034 }
6035
6036 if ( tile < 0 ) // COMBO
6037 {
6038 const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ];
6039 const int32_t tiletodraw = combo_tile(c, x1, y1);
6040 flip = flip ^ c.flip;
6041
6042 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip);
6043 }
6044 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
6045 {
6046 Z_message("Quad() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
6047 return; //non power of two error
6048 }
6049 //Z_scripterrlog("bitmap->Quad() is trying to blit from a bitmap texture.\n");
6050 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
6051 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(h), col[1] };
6052 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(w), static_cast<float>(h), col[2] };
6053 V3D_f V4 = { static_cast<float>(x4+xoffset), static_cast<float>(y4+yoffset), 0, static_cast<float>(w), 0, col[3] };
6054
6055 quad3d_f(refbmp, polytype, tex, &V1, &V2, &V3, &V4);
6056
6057 }
6058
6059
6060
6061
6062 //todo: finish palette shading
6063 /*
6064 POLYTYPE_FLAT
6065 POLYTYPE_GCOL
6066 POLYTYPE_GRGB
6067 POLYTYPE_ATEX
6068 POLYTYPE_PTEX
6069 POLYTYPE_ATEX_MASK
6070 POLYTYPE_PTEX_MASK
6071 POLYTYPE_ATEX_LIT
6072 POLYTYPE_PTEX_LIT
6073 POLYTYPE_ATEX_MASK_LIT
6074 POLYTYPE_PTEX_MASK_LIT
6075 POLYTYPE_ATEX_TRANS
6076 POLYTYPE_PTEX_TRANS
6077 POLYTYPE_ATEX_MASK_TRANS
6078 POLYTYPE_PTEX_MASK_TRANS
6079 */
6080
6081 if(mustDestroyBmp)
6082 destroy_bitmap(tex);
6083
6084 }
6085
6086
6087 void bmp_do_getpixelr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
6088 {
6089 //sdci[1]=layer
6090 //sdci[2]=x1
6091 //sdci[3]=y1
6092
6093 //sdci[17] Bitmap Pointer
6094 if ( sdci[17] <= 0 )
6095 {
6096 Z_scripterrlog("bitmap->GetPixel() wanted to read from an invalid bitmap id: %d. Aborting.\n", sdci[17]);
6097 return;
6098 }
6099 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
6100 if ( refbmp == NULL ) return;
6101
6102
6103 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
6104
6105 int32_t x1 = sdci[2]/10000;
6106 int32_t y1 = (sdci[3]/10000)+yoffset;
6107 int32_t col = getpixel(scb.script_created_bitmaps[(sdci[17]-10)].u_bmp, x1, y1);
6108 Z_scripterrlog("bitmap->GetPixel col is %d\n",col);
6109 Z_scripterrlog("bitmap->GetPixel bitmap ptr is is %d\n",(sdci[17]-10));
6110 FFCore.set_sarg1(col);
6111 }
6112
6113
6114
6115
6116 void bmp_do_drawtriangler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
6117 {
6118 //sdci[1]=layer
6119 //sdci[2]=x1
6120 //sdci[3]=y1
6121 //sdci[4]=x2
6122 //sdci[5]=y2
6123 //sdci[6]=x3
6124 //sdci[7]=y3
6125 //sdci[8]=width
6126 //sdci[9]=height
6127 //sdci[10]=cset
6128 //sdci[11]=flip
6129 //sdci[12]=tile/combo
6130 //sdci[13]=polytype
6131 //sdci[17] Bitmap Pointer
6132 if ( sdci[17] <= 0 )
6133 {
6134 Z_scripterrlog("bitmap->Triangle() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
6135 return;
6136 }
6137 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
6138 if ( refbmp == NULL ) return;
6139
6140
6141 int32_t render_source = sdci[14]-10;
6142 //Z_scripterrlog("bitmap->Triangle() render source is: %d\n", render_source);
6143
6144 bool tex_is_bitmap = ( sdci[14] != 0 );
6145
6146 BITMAP *bmptexture=NULL;
6147 if ( tex_is_bitmap )
6148 {
6149 bmptexture = FFCore.GetScriptBitmap(render_source);
6150 if ( !bmptexture )
6151 {
6152 Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Triangle3()");
6153 tex_is_bitmap = 0;
6154 }
6155 }
6156
6157 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
6158
6159 int32_t x1 = sdci[2]/10000;
6160 int32_t y1 = sdci[3]/10000;
6161 int32_t x2 = sdci[4]/10000;
6162 int32_t y2 = sdci[5]/10000;
6163 int32_t x3 = sdci[6]/10000;
6164 int32_t y3 = sdci[7]/10000;
6165 int32_t w = sdci[8]/10000;
6166 int32_t h = sdci[9]/10000;
6167 int32_t color = sdci[10]/10000;
6168 int32_t flip=(sdci[11]/10000)&3;
6169 int32_t tile = sdci[12]/10000;
6170 int32_t polytype = sdci[13]/10000;
6171
6172 polytype = vbound(polytype, 0, 14);
6173 int32_t utex_w = w;
6174 int32_t utex_h = h;
6175
6176
6177 int32_t tex_width = w*16;
6178 int32_t tex_height = h*16;
6179
6180 bool mustDestroyBmp = false;
6181 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
6182
6183 if(!tex)
6184 {
6185 mustDestroyBmp = true;
6186 tex = create_bitmap_ex(8, tex_width, tex_height);
6187 clear_bitmap(tex);
6188 }
6189
6190 int32_t col[3];
6191 /*
6192 if( color < 0 )
6193 {
6194 col[0]=draw_container.color_buffer[0];
6195 col[1]=draw_container.color_buffer[1];
6196 col[2]=draw_container.color_buffer[2];
6197 }
6198 else */
6199 {
6200 col[0]=col[1]=col[2]=color;
6201 }
6202
6203 if(tile > 0) // TILE
6204 {
6205 TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip);
6206 }
6207 else // COMBO
6208 {
6209 const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ];
6210 const int32_t tiletodraw = combo_tile(c, x1, y1);
6211 flip = flip ^ c.flip;
6212
6213 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip);
6214 }
6215 if ( !tex_is_bitmap )
6216 {
6217 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
6218 {
6219 Z_message("bitmap->Triangle() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
6220 return; //non power of two error
6221 }
6222 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
6223 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(tex_height), col[1] };
6224 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(tex_width), static_cast<float>(tex_height), col[2] };
6225
6226
6227 triangle3d_f(refbmp, polytype, tex, &V1, &V2, &V3);
6228
6229 }
6230
6231 else
6232 {
6233 if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", render_source);
6234 if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", render_source);
6235 if ( !isPowerOfTwo(utex_h) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", utex_w);
6236 if ( !isPowerOfTwo(utex_w) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", utex_h);
6237
6238 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
6239 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(utex_h), col[1] };
6240 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(utex_w), static_cast<float>(utex_h), col[2] };
6241
6242
6243 triangle3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3);
6244
6245 }
6246
6247 if(mustDestroyBmp)
6248 destroy_bitmap(tex);
6249 }
6250
6251
6252 void bmp_do_mode7r(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
6253 {
6254 /*
6255 int32_t layer, int32_t rt, int32_t srcX, int32_t srcY, int32_t srcW, int32_t srcH, int32_t destW, int32_t destH, int32_t angle, int32_t cx, int32_t cy, int32_t space_z, int32_t horizon,
6256 int32_t scale_x, int32_t scale_y){
6257
6258 //sdci[1]=layer
6259 //sdci[2]=bitmap target
6260 //
6261 // -2 is the current Render Target
6262 // -1, this is the screen (framebuf).
6263 // 0: Render target 0
6264 // 1: Render target 1
6265 // 2: Render target 2
6266 // 3: Render target 3
6267 // 4: Render target 4
6268 // 5: Render target 5
6269 // 6: Render target 6
6270 // Otherwise: The pointer to a bitmap.
6271
6272 //sdci[3]=sourcex
6273 //sdci[4]=sourcey
6274 //sdci[5]=sourcew
6275 //sdci[6]=sourceh
6276
6277 //sdci[7]=destw
6278 //sdci[8]=desth
6279 //sdci[9]=angle
6280 //scdi[10] = pivot cx
6281 //sdci[11] = pivot cy
6282 //sdci[12] = space Z
6283 //sdci[13] = horizon
6284 //scdi[14] = scale X
6285 //scdi[15] = scale Y
6286 //sdci[16] = masked?
6287 //sdci[17] Bitmap Pointer
6288
6289
6290
6291 // ZScript-side constant values:
6292 const int32_t BITDX_NORMAL = 0;
6293 const int32_t BITDX_TRANS = 1; //Translucent
6294 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
6295 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
6296 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
6297 //Note: Some modes cannot be combined. if a combination is not supported, an error
6298 // detailing this will be shown in allegro.log.
6299
6300 //scdi[15] = litcolour
6301 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
6302 //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
6303
6304 //sdci[16]=mask
6305
6306 */
6307
6308
6309 int32_t bitmapIndex = sdci[2];
6310 int32_t usr_bitmap_index = sdci[2]-10;
6311 byte using_user_bitmap = 0;
6312 //Z_scripterrlog("bitmap index is: %d\n",bitmapIndex);
6313 //Z_scripterrlog("DrawPlane() bitmapIndex is: %d\n", bitmapIndex);
6314
6315 if ( bitmapIndex >= 10000 )
6316 {
6317 bitmapIndex = bitmapIndex / 10000; //reduce if ZScript sent a raw value, such as bitmap = <int32_t> 8;
6318 }
6319 else if ( usr_bitmap_index > 0 )
6320 {
6321 bitmapIndex = usr_bitmap_index;
6322 using_user_bitmap = 1;
6323 // Z_scripterrlog("Mode7 is using a user bitmap target, pointer: %d\n", usr_bitmap_index);
6324 yoffset = 0;
6325 }
6326
6327 //int32_t sx = sdci[3]/10000;
6328 //int32_t sy = sdci[4]/10000;
6329 //int32_t sw = sdci[5]/10000;
6330 //Z_scripterrlog("sh is: %d\n",sdci[5]/10000);
6331 //int32_t sh = sdci[6]/10000;
6332 //Z_scripterrlog("sh is: %d\n",sdci[6]/10000);
6333 //int32_t dx = sdci[7]/10000;
6334 //int32_t dy = sdci[8]/10000;
6335 //int32_t dw = sdci[9]/10000;
6336 //int32_t dh = sdci[10]/10000;
6337 //float rot = sdci[11]/10000;
6338 //int32_t cx = sdci[12]/10000;
6339 //int32_t cy = sdci[13]/10000;
6340 //int32_t mode = sdci[14]/10000;
6341 //int32_t litcolour = sdci[15]/10000;
6342
6343 //rendering mode 7 args
6344 double srcX = sdci[3]/10000.0;
6345 double srcY = sdci[4]/10000.0;
6346 double destX = sdci[5]/10000.0;
6347 double destY = sdci[6]/10000.0;
6348
6349
6350 // int32_t srcW = sdci[5]/10000;
6351 // int32_t srcH = sdci[6]/10000;
6352 double destW = sdci[7]/10000.0;
6353 double destH = sdci[8]/10000.0;
6354 // int32_t angle = sdci[9]/10000;
6355 // int32_t cx = sdci[10]/10000;
6356 // int32_t cy = sdci[11]/10000;
6357 double space_z = sdci[9]/10000.0;
6358 double horizon = sdci[10]/10000.0;
6359 double scale_x = sdci[11]/10000.0;
6360 double scale_y = sdci[12]/10000.0;
6361 byte masked = ( sdci[13] ) ? 1 : 0;
6362
6363
6364 int32_t ref = 0;
6365
6366 //dx = 0 + xoffset;
6367 //dy = 0 + yoffset;
6368
6369 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
6370 //Do we need to also check the render target and do the same thing if the
6371 //dest == -2 and the render target is not RT_SCREEN?
6372
6373 ref = sdci[17];
6374 //Z_scripterrlog("bitmap->DrawPlane() ref id this frame is: %d\n", ref);
6375 ref -=10;
6376 //Z_scripterrlog("bitmap->DrawPlane() modified ref id this frame is: %d\n", ref);
6377
6378
6379 if ( ref <= 0 )
6380 {
6381 Z_scripterrlog("bitmap->DrawPlane() wanted to use to an invalid source bitmap id: %d. Aborting.\n", ref);
6382 return;
6383 }
6384 BITMAP *sourceBitmap = FFCore.GetScriptBitmap(ref); //This can be the screen, as -1.
6385
6386 if(!sourceBitmap)
6387 {
6388 Z_message("Warning: %d->DrawPlane() source bitmap contains invalid data or is not initialized.\n", ref);
6389 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
6390 return;
6391 }
6392
6393 BITMAP *destBMP=NULL;
6394 //zprint2("mode 7 bitmap index is: %d\n",bitmapIndex);
6395 switch(bitmapIndex)
6396 {
6397 case -2:
6398 {
6399 int32_t curr_rt = zscriptDrawingRenderTarget->GetCurrentRenderTarget();
6400 //zprint2("current RT is: %d\n", curr_rt);
6401 if ( curr_rt >= 0 && curr_rt < 7 )
6402 destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); //Drawing to the current RenderTarget.
6403 else destBMP = bmp; //screen
6404 break;
6405 }
6406 case -1:
6407 destBMP = bmp; //this is framebuf, by default
6408 break;
6409 //zscriptDrawingRenderTarget->SetCurrentRenderTarget(bitmapIndex);
6410 //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
6411 //destBMP = framebuf; //Drawing to the screen.
6412 //break;
6413
6414 //1 through 6 are the old system bitmaps (Render Targets)
6415 case 0:
6416 case 1:
6417 case 2:
6418 case 3:
6419 case 4:
6420 case 5:
6421 case 6:
6422 {
6423 //This gets a render target.
6424 //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); break;
6425
6426 destBMP = zscriptDrawingRenderTarget->GetTargetBitmap(bitmapIndex);
6427 //sdci[18] = bitmapIndex;
6428 break;
6429 }
6430 //Otherwise, we are using a user-created bitmap, so, get that pointer insted.
6431 default:
6432 {
6433 destBMP = scb.script_created_bitmaps[usr_bitmap_index].u_bmp;
6434 //sdci[18] = usr_bitmap_index;
6435 if ( !scb.script_created_bitmaps[usr_bitmap_index].u_bmp )
6436 {
6437 Z_scripterrlog("Target for bitmap->DrawPlane is uninitialised. Aborting.\n");
6438 break;
6439 }
6440 }
6441 //FFCore.get_user_bitmap(bitmapIndex); break;
6442 }
6443
6444 if (!destBMP)
6445 {
6446 Z_message("Warning: DrawPlane(%d) destination bitmap contains invalid data or is not initialized.\n", bitmapIndex);
6447 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
6448 return;
6449 }
6450
6451 //dx = dx + xoffset; //don't do this here!
6452 //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 )
6453 //All of these are a factor of 10000 as fix.
6454 int32_t screen_x = 0; int32_t screen_y = 0;
6455
6456 double distance = 0; double horizontal_scale = 0;
6457
6458 int32_t screen_y_horizon = 0;
6459
6460 double line_dx = 0; double line_dy = 0;
6461
6462 int32_t space_x = 0; int32_t space_y = 0;
6463
6464 for(screen_y = 0; screen_y < destH; screen_y++) //fix, offset by .0000
6465 {
6466 //Calculate the distance of each line from the camera point
6467 screen_y_horizon = screen_y + horizon;
6468
6469 distance = ((space_z * scale_y) / ((screen_y_horizon != 0) ? screen_y_horizon : 1));
6470
6471 //Get the scale of each line based on the distance
6472
6473 horizontal_scale = (distance / (( scale_x != 0 ) ? scale_x : 1));
6474
6475 //There was some math here before I stripped out the rotation step
6476 line_dx = horizontal_scale;
6477 line_dy = 0;
6478
6479 //space_x,space_y - where to grab each scanline from on the space bitmap
6480 space_x = srcX - destW/2.0 * line_dx;
6481 space_y = srcY - distance + destH/2.0 * line_dy;
6482
6483 //Keep blits within the bounds of both bitmaps to avoid crashes
6484 int32_t y1 = srcY+space_y;
6485 int32_t y2 = destY+screen_y;
6486 if(y1 >=0 && y1 <= (sourceBitmap->h-1) && y2 >=0 && y2 <= (destBMP->h-1) )
6487 {
6488 if ( masked ) masked_stretch_blit(sourceBitmap, destBMP, (int32_t)(srcX+space_x), (int32_t)(srcY+space_y),
6489 (int32_t)(line_dx*destW), 1, (int32_t)(screen_x), (int32_t)(screen_y)+yoffset, (int32_t)(destW), 1);
6490 else stretch_blit(sourceBitmap, destBMP, (int32_t)(srcX+space_x), (int32_t)(srcY+space_y),
6491 (int32_t)(line_dx*destW), 1, (int32_t)(screen_x), (int32_t)(screen_y)+yoffset, (int32_t)(destW), 1);
6492 }
6493 }
6494 }
6495
6496
6497 //Draw]()
6498 236166 void bmp_do_drawbitmapexr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
6499 {
6500 /*
6501 //sdci[1]=layer
6502 //sdci[2]=bitmap target
6503 //
6504 // -2 is the current Render Target
6505 // -1, this is the screen (framebuf).
6506 // 0: Render target 0
6507 // 1: Render target 1
6508 // 2: Render target 2
6509 // 3: Render target 3
6510 // 4: Render target 4
6511 // 5: Render target 5
6512 // 6: Render target 6
6513 // Otherwise: The pointer to a bitmap.
6514
6515 //sdci[3]=sourcex
6516 //sdci[4]=sourcey
6517 //sdci[5]=sourcew
6518 //sdci[6]=sourceh
6519 //sdci[7]=destx
6520 //sdci[8]=desty
6521 //sdci[9]=destw
6522 //sdci[10]=desth
6523 //sdci[11]=rotation/angle
6524 //scdi[12] = pivot cx
6525 //sdci[13] = pivot cy
6526 //scdi[14] = effect flags
6527 //sdci[17] Bitmap Pointer
6528
6529 // ZScript-side constant values:
6530 const int32_t BITDX_NORMAL = 0;
6531 const int32_t BITDX_TRANS = 1; //Translucent
6532 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
6533 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
6534 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
6535 //Note: Some modes cannot be combined. if a combination is not supported, an error
6536 // detailing this will be shown in allegro.log.
6537
6538 //scdi[15] = litcolour
6539 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
6540 //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
6541
6542 //sdci[16]=mask
6543
6544 */
6545
6546 236166 int32_t bitmapIndex = sdci[2]/10000;
6547 236166 int32_t usr_bitmap_index = sdci[2]-10;
6548 236166 byte using_user_bitmap = 0;
6549 //Z_scripterrlog("bitmap index is: %d\n",bitmapIndex);
6550 //Z_scripterrlog("Blit() bitmapIndex is: %d\n", bitmapIndex);
6551 #if LOG_BMPBLIT_LEVEL > 0
6552 Z_scripterrlog("Blit() found a dest bitmap ID of: %d\n",bitmapIndex);
6553 #endif
6554
1/2
✓ Branch 0 taken 236166 times.
✗ Branch 1 not taken.
236166 if ( bitmapIndex > 10000 )
6555 {
6556 bitmapIndex = bitmapIndex / 10000; //reduce if ZScript sent a raw value, such as bitmap = <int32_t> 8;
6557 }
6558
3/4
✓ Branch 0 taken 172223 times.
✓ Branch 1 taken 63943 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 172223 times.
236166 if ( usr_bitmap_index > 0 && usr_bitmap_index < 10000 )
6559 {
6560 172223 bitmapIndex = usr_bitmap_index;
6561 172223 using_user_bitmap = 1;
6562 172223 yoffset = 0;
6563 172223 }
6564
6565 236166 int32_t sx = sdci[3]/10000;
6566 236166 int32_t sy = sdci[4]/10000;
6567 236166 int32_t sw = sdci[5]/10000;
6568 //Z_scripterrlog("sh is: %d\n",sdci[5]/10000);
6569 236166 int32_t sh = sdci[6]/10000;
6570 //Z_scripterrlog("sh is: %d\n",sdci[6]/10000);
6571 236166 int32_t dx = sdci[7]/10000;
6572 236166 int32_t dy = sdci[8]/10000;
6573 236166 int32_t dw = sdci[9]/10000;
6574 236166 int32_t dh = sdci[10]/10000;
6575 236166 float rot = sdci[11]/10000;
6576 236166 int32_t cx = sdci[12]/10000;
6577 236166 int32_t cy = sdci[13]/10000;
6578 236166 int32_t mode = sdci[14]/10000;
6579 236166 int32_t litcolour = sdci[15]/10000;
6580 236166 bool masked = (sdci[16] != 0);
6581
6582 236166 int32_t ref = 0;
6583
6584 236166 dx = dx + xoffset;
6585 236166 dy = dy + yoffset;
6586
6587
2/4
✓ Branch 0 taken 236166 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 236166 times.
236166 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
6588 //Do we need to also check the render target and do the same thing if the
6589 //dest == -2 and the render target is not RT_SCREEN?
6590
6591 236166 ref = sdci[17];
6592 //Z_scripterrlog("bitmap->blit() ref id this frame is: %d\n", ref);
6593 236166 ref -=10;
6594 //Z_scripterrlog("bitmap->blit() modified ref id this frame is: %d\n", ref);
6595
6596
6597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236166 times.
236166 if ( ref <= 0 )
6598 {
6599 Z_scripterrlog("bitmap->blit() wanted to use to an invalid source bitmap id: %d. Aborting.\n", ref);
6600 return;
6601 }
6602 236166 BITMAP *sourceBitmap = FFCore.GetScriptBitmap(ref); //This can be the screen, as -1.
6603 #if LOG_BMPBLIT_LEVEL > 0
6604 Z_scripterrlog("bitmap->Blit() is trying to blit to ref: %d\n",sdci[17]);
6605 #endif
6606
1/2
✓ Branch 0 taken 236166 times.
✗ Branch 1 not taken.
236166 if(!sourceBitmap)
6607 {
6608
6609 Z_message("Warning: blit(%d) source bitmap contains invalid data or is not initialized.\n", ref);
6610 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
6611 return;
6612 }
6613
6614 236166 BITMAP *destBMP=NULL;
6615 //zprint2("blit () bitmap index is: %d\n",bitmapIndex);
6616
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 172223 times.
✓ Branch 2 taken 786 times.
✓ Branch 3 taken 63157 times.
236166 switch(bitmapIndex)
6617 {
6618 case -2:
6619 {
6620 786 int32_t curr_rt = zscriptDrawingRenderTarget->GetCurrentRenderTarget();
6621 //zprint2("current RT is: %d\n", curr_rt);
6622
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 786 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
786 if ( curr_rt >= 0 && curr_rt < 7 )
6623 destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); //Drawing to the current RenderTarget.
6624 786 else destBMP = bmp; //screen
6625 786 break;
6626 }
6627 case -1:
6628 63157 destBMP = bmp; //this is framebuf, by default
6629 63157 break;
6630 //zscriptDrawingRenderTarget->SetCurrentRenderTarget(bitmapIndex);
6631 //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
6632 //destBMP = framebuf; //Drawing to the screen.
6633 //break;
6634
6635 //1 through 6 are the old system bitmaps (Render Targets)
6636 case 0:
6637 case 1:
6638 case 2:
6639 case 3:
6640 case 4:
6641 case 5:
6642 case 6:
6643 {
6644 //This gets a render target.
6645 destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); break;
6646
6647 //destBMP = zscriptDrawingRenderTarget->GetTargetBitmap(bitmapIndex);
6648 //sdci[18] = bitmapIndex;
6649 break;
6650 }
6651 //Otherwise, we are using a user-created bitmap, so, get that pointer insted.
6652 default:
6653 {
6654 172223 destBMP = scb.script_created_bitmaps[usr_bitmap_index].u_bmp;
6655 //sdci[18] = usr_bitmap_index;
6656
1/2
✓ Branch 0 taken 172223 times.
✗ Branch 1 not taken.
172223 if ( !scb.script_created_bitmaps[usr_bitmap_index].u_bmp )
6657 {
6658 Z_scripterrlog("Target for bitmap->Blit is uninitialised. Aborting.\n");
6659 break;
6660 }
6661 }
6662 //FFCore.get_user_bitmap(bitmapIndex); break;
6663 172223 }
6664
6665
6666
6667 #if LOG_BMPBLIT_LEVEL > 0
6668 Z_scripterrlog("bitmap->Blit() is trying to blit to dest bitmap ID: %d\n",bitmapIndex);
6669 #endif
6670
6671
6672
1/2
✓ Branch 0 taken 236166 times.
✗ Branch 1 not taken.
236166 if (!destBMP)
6673 {
6674
6675 Z_message("Warning: blit(%d) destination bitmap contains invalid data or is not initialized.\n", bitmapIndex);
6676 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
6677 return;
6678 }
6679
6680 //bugfix
6681 //sx = vbound(sx, 0, sourceBitmap->w);
6682 #if LOG_BMPBLIT_LEVEL > 0
6683 Z_scripterrlog("Blit %s is: %d\n", "sx", sx);
6684 Z_scripterrlog("Blit %s is: %d\n", "source->w", sourceBitmap->w);
6685 #endif
6686 //sy = vbound(sy, 0, sourceBitmap->h);
6687 #if LOG_BMPBLIT_LEVEL > 0
6688 Z_scripterrlog("Blit %s is: %d\n", "sy", sy);
6689 Z_scripterrlog("Blit %s is: %d\n", "source->h", sourceBitmap->h);
6690 #endif
6691 //sw = vbound(sw, 0, sourceBitmap->w - sx); //keep the w/h within range as well
6692 #if LOG_BMPBLIT_LEVEL > 0
6693 Z_scripterrlog("Blit %s is: %d\n", "sw", sw);
6694 #endif
6695 //sh = vbound(sh, 0, sourceBitmap->h - sy);
6696 #if LOG_BMPBLIT_LEVEL > 0
6697 Z_scripterrlog("Blit %s is: %d\n", "sh", sh);
6698
6699 Z_scripterrlog("Blit %s is: %d\n", "dh", dh);
6700 Z_scripterrlog("Blit %s is: %d\n", "dw", dw);
6701 #endif
6702
2/2
✓ Branch 0 taken 1027 times.
✓ Branch 1 taken 235139 times.
236166 bool stretched = (sw != dw || sh != dh);
6703 //bool stretched = (sourceBitmap->w != destBMP->w || sourceBitmap->h != destBMP->h);
6704 #if LOG_BMPBLIT_LEVEL > 0
6705 Z_scripterrlog("Blit %s is: %s\n", "stretched", stretched ? "true" : "false");
6706 #endif
6707 //BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
6708
6709
6710
6711
6712
6713 236166 BITMAP* subBmp = 0;
6714
6715 /* IDR what this was. -Z ( 17th April, 2019 )
6716 if ( bitmapIndex == -1 ) {
6717 blit(bmp, sourceBitmap, sx, sy, 0, 0, dw, dh);
6718 }
6719 */
6720
6721
4/4
✓ Branch 0 taken 234587 times.
✓ Branch 1 taken 1579 times.
✓ Branch 2 taken 24951 times.
✓ Branch 3 taken 209636 times.
236166 if(rot != 0 || mode != 0)
6722 {
6723 26530 subBmp = create_bitmap_ex(8,sourceBitmap->w, sourceBitmap->h);//script_drawing_commands.AquireSubBitmap(dw, dh);
6724 26530 clear_bitmap(subBmp);
6725
6726
1/2
✓ Branch 0 taken 26530 times.
✗ Branch 1 not taken.
26530 if(!subBmp)
6727 {
6728
6729 Z_scripterrlog("bitmap->Blit failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation");
6730 return;
6731 }
6732 26530 }
6733 236166 BITMAP* sbmp = sourceBitmap;
6734
2/4
✓ Branch 0 taken 236166 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 236166 times.
236166 if (sx + sw > sbmp->w || sy + sh > sbmp->h)
6735 {
6736 sbmp = create_bitmap_ex(8, sw, sh);
6737 clear_bitmap(sbmp);
6738 blit(sourceBitmap, sbmp, sx, sy, 0, 0, std::min(sourceBitmap->w-sx, sw), std::min(sourceBitmap->h-sy, sh));
6739 sx = 0;
6740 sy = 0;
6741 }
6742 //dx = dx + xoffset; //don't do this here!
6743 //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 )
6744
6745
2/2
✓ Branch 0 taken 1602 times.
✓ Branch 1 taken 234564 times.
236166 if(stretched)
6746 {
6747
2/2
✓ Branch 0 taken 1475 times.
✓ Branch 1 taken 127 times.
1602 if(masked)
6748 { //stretched and masked
6749
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 901 times.
1475 if ( rot == 0 )
6750 { //if not rotated
6751
2/22
✗ Branch 0 not taken.
✓ Branch 1 taken 900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 times.
901 switch(mode)
6752 {
6753 case 1:
6754 //transparent
6755 900 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6756 900 draw_trans_sprite(destBMP, subBmp, dx, dy);
6757 900 break;
6758
6759
6760 case 2:
6761 //pivot?
6762 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6763 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6764 //Pivoting requires two more args
6765 break;
6766
6767 case 3:
6768 //pivot + trans
6769 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6770 pivot_sprite_trans(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6771 break;
6772
6773 case 4:
6774 //flip v
6775 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6776 draw_sprite_v_flip(destBMP, subBmp, dx, dy);
6777 break;
6778
6779 case 5:
6780 //trans + v flip
6781 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6782 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
6783 break;
6784
6785 case 6:
6786 //pivot + v flip
6787 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6788 pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6789 break;
6790
6791 case 8:
6792 //vlip h
6793 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6794 draw_sprite_h_flip(destBMP, subBmp, dx, dy);
6795 break;
6796
6797 case 9:
6798 //trans + h flip
6799 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6800 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
6801 break;
6802
6803 case 10:
6804 //flip H and pivot
6805 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
6806 //return error cannot pivot and h flip
6807 break;
6808
6809 case 12:
6810 //vh flip
6811 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6812 draw_sprite_vh_flip(destBMP, subBmp, dx, dy);
6813 break;
6814
6815 case 13:
6816 //trans + vh flip
6817 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6818 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
6819 break;
6820
6821 case 14:
6822 //pivot and vh flip
6823 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
6824 //return error cannot both pivot and vh flip
6825 break;
6826
6827 case 16:
6828 //lit
6829 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6830 draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour);
6831 break;
6832
6833 case 18:
6834 //pivot, lit
6835 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6836 pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
6837 break;
6838
6839 case 20:
6840 //lit + v flip
6841 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6842 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
6843 break;
6844
6845 case 22:
6846 //Pivot, vflip, lit
6847 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6848 pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
6849 break;
6850
6851 case 24:
6852 //lit + h flip
6853 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6854 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
6855 break;
6856
6857 case 26:
6858 //pivot + lit + hflip
6859 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
6860 //return error cannot pivot, lit, and flip
6861 break;
6862
6863 case 28:
6864 //lit + vh flip
6865 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6866 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
6867 break;
6868
6869 case 32: //gouraud
6870 //Probably not wort supporting.
6871 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6872 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
6873 break;
6874
6875 case 0:
6876 //no effect
6877 1 masked_stretch_blit(sbmp, destBMP, sx, sy, sw, sh, dx, dy, dw, dh);
6878 1 break;
6879
6880
6881 default:
6882
6883 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
6884
6885
6886 }
6887 901 } //end if not rotated
6888
6889
2/2
✓ Branch 0 taken 901 times.
✓ Branch 1 taken 574 times.
1475 if ( rot != 0 ) //if rotated
6890 {
6891
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 574 times.
✗ Branch 21 not taken.
574 switch(mode)
6892 {
6893 case 1:
6894 //transparent
6895 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6896 rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
6897
6898 break;
6899
6900 case 2:
6901 //pivot?
6902 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6903 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6904 //Pivoting requires two more args
6905 break;
6906
6907 case 3:
6908 //pivot + trans
6909 //return an error, cannot both rotate and pivot
6910 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
6911 break;
6912
6913 case 4:
6914 //flip v
6915 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6916 rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
6917 break;
6918
6919 case 5:
6920 //trans + v flip
6921 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6922 rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
6923 break;
6924
6925 case 6:
6926 //pivot + v flip
6927 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
6928 //return an error, cannot both rotate and pivot
6929 break;
6930
6931 case 8:
6932 //flip h
6933 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
6934 //return an error, cannot both rotate and flip H
6935 break;
6936
6937 case 9:
6938 //trans + h flip
6939 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
6940 //return an error, cannot rotate and flip a trans sprite
6941 break;
6942
6943 case 10:
6944 //flip H and pivot
6945 //return error cannot pivot and h flip
6946 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
6947 break;
6948
6949 case 12:
6950 //vh flip
6951 //return an error, cannot rotate and VH flip a trans sprite
6952 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
6953 break;
6954
6955 case 13:
6956 //trans + vh flip
6957 //return an error, cannot rotate and VH flip a trans sprite
6958 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
6959 break;
6960
6961 case 14:
6962 //pivot and vh flip
6963 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
6964 //return error cannot both pivot and vh flip
6965 break;
6966
6967 case 16:
6968 //lit
6969 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6970 rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
6971 break;
6972
6973 case 18:
6974 //pivot, lit
6975 //return an error, cannot both rotate and pivot
6976 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
6977 break;
6978
6979 case 20:
6980 //lit + vflip
6981 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6982 rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
6983 break;
6984
6985 case 22:
6986 //Pivot, vflip, lit
6987 //return an error, cannot both rotate and pivot
6988 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
6989 break;
6990
6991 case 24:
6992 //lit + h flip
6993 //return an error, cannot both rotate and H flip
6994 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
6995 break;
6996
6997 case 26:
6998 //pivot + lit + hflip
6999 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
7000 //return error cannot pivot, lit, and flip
7001 break;
7002
7003 case 28:
7004 //lit + vh flip
7005 //return an error, cannot both rotate and VH flip
7006 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7007 break;
7008
7009 case 32: //gouraud
7010 //Probably not wort supporting.
7011 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7012 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7013 break;
7014
7015 case 0:
7016 //no effect.
7017 574 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7018 574 rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7019 574 break;
7020
7021 default:
7022
7023 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7024
7025 }
7026 574 }
7027 1475 } //end if stretched and masked
7028
7029 else //stretched, not masked
7030 {
7031
7032
7033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if ( rot == 0 ) //if not rotated
7034 {
7035
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 127 times.
127 switch(mode)
7036 {
7037 case 1:
7038 //transparent
7039 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7040 draw_trans_sprite(destBMP, subBmp, dx, dy);
7041 break;
7042
7043
7044 case 2:
7045 //pivot?
7046 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7047 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7048 //Pivoting requires two more args
7049 break;
7050
7051 case 3:
7052 //pivot + trans
7053 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7054 pivot_sprite_trans(destBMP, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot));
7055 break;
7056
7057 case 4:
7058 //flip v
7059 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7060 draw_sprite_v_flip(destBMP, subBmp, dx, dy);
7061 break;
7062
7063 case 5:
7064 //trans + v flip
7065 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7066 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
7067 break;
7068
7069 case 6:
7070 //pivot + v flip
7071 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7072 pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7073 break;
7074
7075 case 8:
7076 //vlip h
7077 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7078 draw_sprite_h_flip(destBMP, subBmp, dx, dy);
7079 break;
7080
7081 case 9:
7082 //trans + h flip
7083 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7084 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
7085 break;
7086
7087 case 10:
7088 //flip H and pivot
7089 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7090 //return error cannot pivot and h flip
7091 break;
7092
7093 case 12:
7094 //vh flip
7095 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7096 draw_sprite_vh_flip(destBMP, subBmp, dx, dy);
7097 break;
7098
7099 case 13:
7100 //trans + vh flip
7101 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7102 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
7103 break;
7104
7105 case 14:
7106 //pivot and vh flip
7107 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7108 //return error cannot both pivot and vh flip
7109 break;
7110
7111 case 16:
7112 //lit
7113 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7114 draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour);
7115 break;
7116
7117 case 18:
7118 //pivot, lit
7119 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7120 pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7121 break;
7122
7123 case 20:
7124 //lit + v flip
7125 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7126 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
7127 break;
7128
7129 case 22:
7130 //Pivot, vflip, lit
7131 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7132 pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7133 break;
7134
7135 case 24:
7136 //lit + h flip
7137 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7138 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
7139 break;
7140
7141 case 26:
7142 //pivot + lit + hflip
7143 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
7144 //return error cannot pivot, lit, and flip
7145 break;
7146
7147 case 28:
7148 //lit + vh flip
7149 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7150 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
7151 break;
7152
7153 case 32: //gouraud
7154 //Probably not wort supporting.
7155 //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7156 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7157 break;
7158
7159 case 0:
7160 //no effect
7161 127 stretch_blit(sbmp, destBMP, sx, sy, sw, sh, dx, dy, dw, dh);
7162 127 break;
7163
7164
7165 default:
7166
7167 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7168
7169
7170 }
7171 127 } //end if not rotated
7172
7173
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if ( rot != 0 ) //if rotated
7174 {
7175 switch(mode)
7176 {
7177 case 1:
7178 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
7179 rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7180
7181 break;
7182
7183 case 2:
7184 //pivot?
7185 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7186 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7187 //Pivoting requires two more args
7188 break;
7189
7190 case 3:
7191 //pivot + trans
7192 //return an error, cannot both rotate and pivot
7193 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7194 break;
7195
7196 case 4:
7197 //flip v
7198 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7199 rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7200 break;
7201
7202 case 5:
7203 //trans + v flip
7204 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7205 rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7206 break;
7207
7208 case 6:
7209 //pivot + v flip
7210 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7211 //return an error, cannot both rotate and pivot
7212 break;
7213
7214 case 8:
7215 //flip h
7216 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
7217 //return an error, cannot both rotate and flip H
7218 break;
7219
7220 case 9:
7221 //trans + h flip
7222 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
7223 //return an error, cannot rotate and flip a trans sprite
7224 break;
7225
7226 case 10:
7227 //flip H and pivot
7228 //return error cannot pivot and h flip
7229 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7230 break;
7231
7232 case 12:
7233 //vh flip
7234 //return an error, cannot rotate and VH flip a trans sprite
7235 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7236 break;
7237
7238 case 13:
7239 //trans + vh flip
7240 //return an error, cannot rotate and VH flip a trans sprite
7241 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7242 break;
7243
7244 case 14:
7245 //pivot and vh flip
7246 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7247 //return error cannot both pivot and vh flip
7248 break;
7249
7250 case 16:
7251 //lit
7252 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
7253 rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7254 break;
7255
7256 case 18:
7257 //pivot, lit
7258 //return an error, cannot both rotate and pivot
7259 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7260 break;
7261
7262 case 20:
7263 //lit + vflip
7264 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
7265 rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7266 break;
7267
7268 case 22:
7269 //Pivot, vflip, lit
7270 //return an error, cannot both rotate and pivot
7271 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7272 break;
7273
7274 case 24:
7275 //lit + h flip
7276 //return an error, cannot both rotate and H flip
7277 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
7278 break;
7279
7280 case 26:
7281 //pivot + lit + hflip
7282 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
7283 //return error cannot pivot, lit, and flip
7284 break;
7285
7286 case 28:
7287 //lit + vh flip
7288 //return an error, cannot both rotate and VH flip
7289 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7290 break;
7291
7292 case 32: //gouraud
7293 //Probably not wort supporting.
7294 //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7295 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7296 break;
7297
7298 case 0:
7299 //no effect.
7300 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7301 rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7302 break;
7303
7304 default:
7305
7306 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7307
7308 }
7309 }
7310
7311 } //end if stretched, but not masked
7312 1602 }
7313 else //not stretched
7314 {
7315
7316
2/2
✓ Branch 0 taken 223581 times.
✓ Branch 1 taken 10983 times.
234564 if(masked) //if masked, but not stretched
7317 {
7318
7319
2/2
✓ Branch 0 taken 1005 times.
✓ Branch 1 taken 222576 times.
223581 if ( rot == 0 ) //if not rotated
7320 {
7321
2/22
✗ Branch 0 not taken.
✓ Branch 1 taken 18657 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 203919 times.
222576 switch(mode)
7322 {
7323 case 1:
7324 //transparent
7325 18657 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7326 18657 draw_trans_sprite(destBMP, subBmp, dx, dy);
7327 18657 break;
7328
7329
7330 case 2:
7331 //pivot?
7332 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7333 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7334 //Pivoting requires two more args
7335 break;
7336
7337 case 3:
7338 //pivot + trans
7339 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7340 pivot_sprite_trans(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7341 break;
7342
7343 case 4:
7344 //flip v
7345 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7346 draw_sprite_v_flip(destBMP, subBmp, dx, dy);
7347 break;
7348
7349 case 5:
7350 //trans + v flip
7351 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7352 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
7353 break;
7354
7355 case 6:
7356 //pivot + v flip
7357 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7358 pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7359 break;
7360
7361 case 8:
7362 //vlip h
7363 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7364 draw_sprite_h_flip(destBMP, subBmp, dx, dy);
7365 break;
7366
7367 case 9:
7368 //trans + h flip
7369 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7370 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
7371 break;
7372
7373 case 10:
7374 //flip H and pivot
7375 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7376 //return error cannot pivot and h flip
7377 break;
7378
7379 case 12:
7380 //vh flip
7381 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7382 draw_sprite_vh_flip(destBMP, subBmp, dx, dy);
7383 break;
7384
7385 case 13:
7386 //trans + vh flip
7387 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7388 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
7389 break;
7390
7391 case 14:
7392 //pivot and vh flip
7393 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7394 //return error cannot both pivot and vh flip
7395 break;
7396
7397 case 16:
7398 //lit
7399 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7400 draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour);
7401 break;
7402
7403 case 18:
7404 //pivot, lit
7405 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7406 pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7407 break;
7408
7409 case 20:
7410 //lit + v flip
7411 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7412 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
7413 break;
7414
7415 case 22:
7416 //Pivot, vflip, lit
7417 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7418 pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7419 break;
7420
7421 case 24:
7422 //lit + h flip
7423 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7424 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
7425 break;
7426
7427 case 26:
7428 //pivot + lit + hflip
7429 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
7430 //return error cannot pivot, lit, and flip
7431 break;
7432
7433 case 28:
7434 //lit + vh flip
7435 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7436 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
7437 break;
7438
7439 case 32: //gouraud
7440 //Probably not wort supporting.
7441 //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7442 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7443 break;
7444
7445 case 0:
7446 //no effect
7447 203919 masked_blit(sbmp, destBMP, sx, sy, dx, dy, dw, dh);
7448 203919 break;
7449
7450
7451 default:
7452
7453 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7454
7455
7456 }
7457 222576 } //end if not rotated
7458
7459
2/2
✓ Branch 0 taken 222576 times.
✓ Branch 1 taken 1005 times.
223581 if ( rot != 0 ) //if rotated
7460 {
7461
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 1005 times.
✗ Branch 21 not taken.
1005 switch(mode)
7462 {
7463 case 1:
7464 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); //transparent
7465 rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7466
7467 break;
7468
7469 case 2:
7470 //pivot?
7471 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7472 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7473 //Pivoting requires two more args
7474 break;
7475
7476 case 3:
7477 //pivot + trans
7478 //return an error, cannot both rotate and pivot
7479 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7480 break;
7481
7482 case 4:
7483 //flip v
7484 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7485 rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7486 break;
7487
7488 case 5:
7489 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip
7490 rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7491 break;
7492
7493 case 6:
7494 //pivot + v flip
7495 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7496 //return an error, cannot both rotate and pivot
7497 break;
7498
7499 case 8:
7500 //flip h
7501 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
7502 //return an error, cannot both rotate and flip H
7503 break;
7504
7505 case 9:
7506 //trans + h flip
7507 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
7508 //return an error, cannot rotate and flip a trans sprite
7509 break;
7510
7511 case 10:
7512 //flip H and pivot
7513 //return error cannot pivot and h flip
7514 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7515 break;
7516
7517 case 12:
7518 //vh flip
7519 //return an error, cannot rotate and VH flip a trans sprite
7520 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7521 break;
7522
7523 case 13:
7524 //trans + vh flip
7525 //return an error, cannot rotate and VH flip a trans sprite
7526 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7527 break;
7528
7529 case 14:
7530 //pivot and vh flip
7531 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7532 //return error cannot both pivot and vh flip
7533 break;
7534
7535 case 16:
7536 //lit
7537 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7538 rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7539 break;
7540
7541 case 18:
7542 //pivot, lit
7543 //return an error, cannot both rotate and pivot
7544 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7545 break;
7546
7547 case 20:
7548 //lit + vflip
7549 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7550 rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7551 break;
7552
7553 case 22:
7554 //Pivot, vflip, lit
7555 //return an error, cannot both rotate and pivot
7556 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7557 break;
7558
7559 case 24:
7560 //lit + h flip
7561 //return an error, cannot both rotate and H flip
7562 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
7563 break;
7564
7565 case 26:
7566 //pivot + lit + hflip
7567 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
7568 //return error cannot pivot, lit, and flip
7569 break;
7570
7571 case 28:
7572 //lit + vh flip
7573 //return an error, cannot both rotate and VH flip
7574 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7575 break;
7576
7577 case 32: //gouraud
7578 //Probably not wort supporting.
7579 //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7580 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7581 break;
7582
7583 case 0:
7584 //no effect.
7585 1005 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7586 1005 rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7587 1005 break;
7588
7589 default:
7590
7591 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7592
7593 }
7594 1005 } //end rtated, masked
7595 223581 } //end if masked
7596
7597 else //not masked, and not stretched; just blit
7598 {
7599
7600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10983 times.
10983 if ( rot == 0 ) //if not rotated
7601 {
7602
2/22
✗ Branch 0 not taken.
✓ Branch 1 taken 5394 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 5589 times.
10983 switch(mode)
7603 {
7604 case 1:
7605 //transparent
7606 5394 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7607 5394 draw_trans_sprite(destBMP, subBmp, dx, dy);
7608 5394 break;
7609
7610
7611 case 2:
7612 //pivot?
7613 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7614 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7615 //Pivoting requires two more args
7616 break;
7617
7618 case 3:
7619 //pivot + trans
7620 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7621 pivot_sprite_trans(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7622 break;
7623
7624 case 4:
7625 //flip v
7626 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7627 draw_sprite_v_flip(destBMP, subBmp, dx, dy);
7628 break;
7629
7630 case 5:
7631 //trans + v flip
7632 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7633 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
7634 break;
7635
7636 case 6:
7637 //pivot + v flip
7638 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7639 pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7640 break;
7641
7642 case 8:
7643 //vlip h
7644 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7645 draw_sprite_h_flip(destBMP, subBmp, dx, dy);
7646 break;
7647
7648 case 9:
7649 //trans + h flip
7650 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7651 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
7652 break;
7653
7654 case 10:
7655 //flip H and pivot
7656 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7657 //return error cannot pivot and h flip
7658 break;
7659
7660 case 12:
7661 //vh flip
7662 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7663 draw_sprite_vh_flip(destBMP, subBmp, dx, dy);
7664 break;
7665
7666 case 13:
7667 //trans + vh flip
7668 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7669 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
7670 break;
7671
7672 case 14:
7673 //pivot and vh flip
7674 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7675 //return error cannot both pivot and vh flip
7676 break;
7677
7678 case 16:
7679 //lit
7680 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7681 draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour);
7682 break;
7683
7684 case 18:
7685 //pivot, lit
7686 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7687 pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7688 break;
7689
7690 case 20:
7691 //lit + v flip
7692 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7693 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
7694 break;
7695
7696 case 22:
7697 //Pivot, vflip, lit
7698 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7699 pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7700 break;
7701
7702 case 24:
7703 //lit + h flip
7704 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7705 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
7706 break;
7707
7708 case 26:
7709 //pivot + lit + hflip
7710 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
7711 //return error cannot pivot, lit, and flip
7712 break;
7713
7714 case 28:
7715 //lit + vh flip
7716 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7717 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
7718 break;
7719
7720 case 32: //gouraud
7721 //Probably not wort supporting.
7722 //blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7723 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7724 break;
7725
7726 case 0:
7727 //no effect
7728 5589 blit(sbmp, destBMP, sx, sy, dx, dy, dw, dh);
7729 5589 break;
7730
7731
7732 default:
7733
7734 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7735
7736
7737 }
7738 10983 } //end if not rotated
7739
7740
1/2
✓ Branch 0 taken 10983 times.
✗ Branch 1 not taken.
10983 if ( rot != 0 ) //if rotated
7741 {
7742 switch(mode)
7743 {
7744 case 1:
7745 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);//transparent
7746 rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7747
7748 break;
7749
7750 case 2:
7751 //pivot?
7752 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7753 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7754 //Pivoting requires two more args
7755 break;
7756
7757 case 3:
7758 //pivot + trans
7759 //return an error, cannot both rotate and pivot
7760 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7761 break;
7762
7763 case 4:
7764 //flip v
7765 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7766 rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7767 break;
7768
7769 case 5:
7770 //trans + v flip
7771 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7772 rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7773 break;
7774
7775 case 6:
7776 //pivot + v flip
7777 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7778 //return an error, cannot both rotate and pivot
7779 break;
7780
7781 case 8:
7782 //flip h
7783 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
7784 //return an error, cannot both rotate and flip H
7785 break;
7786
7787 case 9:
7788 //trans + h flip
7789 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
7790 //return an error, cannot rotate and flip a trans sprite
7791 break;
7792
7793 case 10:
7794 //flip H and pivot
7795 //return error cannot pivot and h flip
7796 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7797 break;
7798
7799 case 12:
7800 //vh flip
7801 //return an error, cannot rotate and VH flip a trans sprite
7802 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7803 break;
7804
7805 case 13:
7806 //trans + vh flip
7807 //return an error, cannot rotate and VH flip a trans sprite
7808 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7809 break;
7810
7811 case 14:
7812 //pivot and vh flip
7813 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7814 //return error cannot both pivot and vh flip
7815 break;
7816
7817 case 16:
7818 //lit
7819 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7820 rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7821 break;
7822
7823 case 18:
7824 //pivot, lit
7825 //return an error, cannot both rotate and pivot
7826 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7827 break;
7828
7829 case 20:
7830 //lit + vflip
7831 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7832 rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7833 break;
7834
7835 case 22:
7836 //Pivot, vflip, lit
7837 //return an error, cannot both rotate and pivot
7838 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7839 break;
7840
7841 case 24:
7842 //lit + h flip
7843 //return an error, cannot both rotate and H flip
7844 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
7845 break;
7846
7847 case 26:
7848 //pivot + lit + hflip
7849 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
7850 //return error cannot pivot, lit, and flip
7851 break;
7852
7853 case 28:
7854 //lit + vh flip
7855 //return an error, cannot both rotate and VH flip
7856 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7857 break;
7858
7859 case 32: //gouraud
7860 //Probably not wort supporting.
7861 //blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7862 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7863 break;
7864
7865 case 0:
7866 //no effect.
7867 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7868 rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7869 break;
7870
7871 default:
7872
7873 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7874
7875 }
7876 } //end if rotated
7877 } //end if not masked
7878 } //end if not stretched
7879
7880 //cleanup
7881
2/2
✓ Branch 0 taken 26530 times.
✓ Branch 1 taken 209636 times.
236166 if(subBmp)
7882 {
7883 //script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap.
7884 26530 destroy_bitmap(subBmp);
7885 26530 }
7886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236166 times.
236166 if (sbmp != sourceBitmap)
7887 {
7888 destroy_bitmap(sbmp);
7889 }
7890 236166 }
7891
7892
7893
7894 909 void bmp_do_blittor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
7895 {
7896 /*
7897 //sdci[1]=layer
7898 //sdci[2]=bitmap target
7899 //
7900 // -2 is the current Render Target
7901 // -1, this is the screen (framebuf).
7902 // 0: Render target 0
7903 // 1: Render target 1
7904 // 2: Render target 2
7905 // 3: Render target 3
7906 // 4: Render target 4
7907 // 5: Render target 5
7908 // 6: Render target 6
7909 // Otherwise: The pointer to a bitmap.
7910
7911 //sdci[3]=sourcex
7912 //sdci[4]=sourcey
7913 //sdci[5]=sourcew
7914 //sdci[6]=sourceh
7915 //sdci[7]=destx
7916 //sdci[8]=desty
7917 //sdci[9]=destw
7918 //sdci[10]=desth
7919 //sdci[11]=rotation/angle
7920 //scdi[12] = pivot cx
7921 //sdci[13] = pivot cy
7922 //scdi[14] = effect flags
7923 //sdci[17] Bitmap Pointer
7924
7925 // ZScript-side constant values:
7926 const int32_t BITDX_NORMAL = 0;
7927 const int32_t BITDX_TRANS = 1; //Translucent
7928 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
7929 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
7930 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
7931 //Note: Some modes cannot be combined. if a combination is not supported, an error
7932 // detailing this will be shown in allegro.log.
7933
7934 //scdi[15] = litcolour
7935 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7936 //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
7937
7938 //sdci[16]=mask
7939
7940 */
7941
7942 909 int32_t srcyoffset = yoffset, srcxoffset = xoffset;
7943 909 int32_t bitmapIndex = sdci[2]/10000;
7944 909 int32_t usr_bitmap_index = sdci[2]-10;
7945 909 byte using_user_bitmap = 0;
7946 //Z_scripterrlog("bitmap index is: %d\n",bitmapIndex);
7947 //Z_scripterrlog("Blit() bitmapIndex is: %d\n", bitmapIndex);
7948 #if LOG_BMPBLIT_LEVEL > 0
7949 Z_scripterrlog("Blit() found a dest bitmap ID of: %d\n",bitmapIndex);
7950 #endif
7951
1/2
✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
909 if ( bitmapIndex > 10000 )
7952 {
7953 bitmapIndex = bitmapIndex / 10000; //reduce if ZScript sent a raw value, such as bitmap = <int32_t> 8;
7954 }
7955
3/4
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 906 times.
909 if ( usr_bitmap_index > 0 && usr_bitmap_index < 10000 )
7956 {
7957 906 bitmapIndex = usr_bitmap_index;
7958 906 using_user_bitmap = 1;
7959 906 srcyoffset = 0;
7960 906 }
7961
7962 909 int32_t sx = sdci[3]/10000;
7963 909 int32_t sy = sdci[4]/10000;
7964 909 int32_t sw = sdci[5]/10000;
7965 //Z_scripterrlog("sh is: %d\n",sdci[5]/10000);
7966 909 int32_t sh = sdci[6]/10000;
7967 //Z_scripterrlog("sh is: %d\n",sdci[6]/10000);
7968 909 int32_t dx = sdci[7]/10000;
7969 909 int32_t dy = sdci[8]/10000;
7970 909 int32_t dw = sdci[9]/10000;
7971 909 int32_t dh = sdci[10]/10000;
7972 909 float rot = sdci[11]/10000;
7973 909 int32_t cx = sdci[12]/10000;
7974 909 int32_t cy = sdci[13]/10000;
7975 909 int32_t mode = sdci[14]/10000;
7976 909 int32_t litcolour = sdci[15]/10000;
7977 909 bool masked = (sdci[16] != 0);
7978
7979 909 int32_t ref = 0;
7980
7981 //These should go down farther, should they not? -V
7982 //dx = dx + xoffset;
7983 //dy = dy + yoffset;
7984
7985
2/4
✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 909 times.
909 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
7986
3/4
✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 906 times.
909 if ( (bitmapIndex) != -2 && (bitmapIndex) != -1 ) srcyoffset = 0; //Don't crop.
7987 //Do we need to also check the render target and do the same thing if the
7988 //dest == -2 and the render target is not RT_SCREEN?
7989 909 dx = dx + xoffset;
7990 909 dy = dy + yoffset;
7991 909 sx = sx + srcxoffset;
7992 909 sy = sy + srcyoffset;
7993
7994 909 ref = sdci[17];
7995 //Z_scripterrlog("bitmap->blit() ref id this frame is: %d\n", ref);
7996 909 ref -=10;
7997 //Z_scripterrlog("bitmap->blit() modified ref id this frame is: %d\n", ref);
7998
7999
8000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 909 times.
909 if ( ref <= 0 )
8001 {
8002 Z_scripterrlog("bitmap->blit() wanted to use to an invalid source bitmap id: %d. Aborting.\n", ref);
8003 return;
8004 }
8005 909 BITMAP *sourceBitmap = FFCore.GetScriptBitmap(ref); //This can be the screen, as -1.
8006 #if LOG_BMPBLIT_LEVEL > 0
8007 Z_scripterrlog("bitmap->Blit() is trying to blit to ref: %d\n",sdci[17]);
8008 #endif
8009
1/2
✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
909 if(!sourceBitmap)
8010 {
8011 Z_message("Warning: blit(%d) source bitmap contains invalid data or is not initialized.\n", ref);
8012 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
8013 return;
8014 }
8015
8016 909 BITMAP *destBMP=NULL;
8017 //zprint2("RevBlit bitmap index is: %d\n",bitmapIndex);
8018
8019
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
909 switch(bitmapIndex)
8020 {
8021 case -2:
8022 {
8023 int32_t curr_rt = zscriptDrawingRenderTarget->GetCurrentRenderTarget();
8024 //zprint2("current RT is: %d\n", curr_rt);
8025 if ( curr_rt >= 0 && curr_rt < 7 )
8026 destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); //Drawing to the current RenderTarget.
8027 else destBMP = bmp; //screen
8028 break;
8029 }
8030 case -1:
8031 3 destBMP = bmp; //this is framebuf, by default
8032 3 break;
8033 //zscriptDrawingRenderTarget->SetCurrentRenderTarget(bitmapIndex);
8034 //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
8035 //destBMP = framebuf; //Drawing to the screen.
8036 //break;
8037
8038 //1 through 6 are the old system bitmaps (Render Targets)
8039 case 0:
8040 case 1:
8041 case 2:
8042 case 3:
8043 case 4:
8044 case 5:
8045 case 6:
8046 {
8047 //This gets a render target.
8048 //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); break;
8049
8050 destBMP = zscriptDrawingRenderTarget->GetTargetBitmap(bitmapIndex);
8051 //sdci[18] = bitmapIndex;
8052 break;
8053 }
8054 //Otherwise, we are using a user-created bitmap, so, get that pointer insted.
8055 default:
8056 {
8057 906 destBMP = scb.script_created_bitmaps[usr_bitmap_index].u_bmp;
8058 //sdci[18] = usr_bitmap_index;
8059
1/2
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
906 if ( !scb.script_created_bitmaps[usr_bitmap_index].u_bmp )
8060 {
8061 Z_scripterrlog("Target for bitmap->Blit is uninitialised. Aborting.\n");
8062 break;
8063 }
8064 }
8065 //FFCore.get_user_bitmap(bitmapIndex); break;
8066 906 }
8067
8068 #if LOG_BMPBLIT_LEVEL > 0
8069 Z_scripterrlog("bitmap->Blit() is trying to blit to dest bitmap ID: %d\n",bitmapIndex);
8070 #endif
8071
8072
8073
1/2
✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
909 if (!destBMP)
8074 {
8075 Z_message("Warning: blit(%d) destination bitmap contains invalid data or is not initialized.\n", bitmapIndex);
8076 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
8077 return;
8078 }
8079
8080 //bugfix
8081 //sx = vbound(sx, 0, sourceBitmap->w);
8082 #if LOG_BMPBLIT_LEVEL > 0
8083 Z_scripterrlog("Blit %s is: %d\n", "sx", sx);
8084 Z_scripterrlog("Blit %s is: %d\n", "source->w", sourceBitmap->w);
8085 #endif
8086 //sy = vbound(sy, 0, sourceBitmap->h);
8087 #if LOG_BMPBLIT_LEVEL > 0
8088 Z_scripterrlog("Blit %s is: %d\n", "sy", sy);
8089 Z_scripterrlog("Blit %s is: %d\n", "source->h", sourceBitmap->h);
8090 #endif
8091 //sw = vbound(sw, 0, sourceBitmap->w - sx); //keep the w/h within range as well
8092 #if LOG_BMPBLIT_LEVEL > 0
8093 Z_scripterrlog("Blit %s is: %d\n", "sw", sw);
8094 #endif
8095 //sh = vbound(sh, 0, sourceBitmap->h - sy);
8096 #if LOG_BMPBLIT_LEVEL > 0
8097 Z_scripterrlog("Blit %s is: %d\n", "sh", sh);
8098
8099 Z_scripterrlog("Blit %s is: %d\n", "dx", dx);
8100 Z_scripterrlog("Blit %s is: %d\n", "dy", dy);
8101 Z_scripterrlog("Blit %s is: %d\n", "dh", dh);
8102 Z_scripterrlog("Blit %s is: %d\n", "dw", dw);
8103 Z_scripterrlog("Blit %s is: %d\n", "yoffset", yoffset);
8104 #endif
8105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 909 times.
909 bool stretched = (sw != dw || sh != dh);
8106 //bool stretched = (sourceBitmap->w != destBMP->w || sourceBitmap->h != destBMP->h);
8107 #if LOG_BMPBLIT_LEVEL > 0
8108 Z_scripterrlog("Blit %s is: %s\n", "stretched", stretched ? "true" : "false");
8109 #endif
8110 //BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
8111
8112
8113
8114 909 BITMAP* newDest = sourceBitmap;
8115 909 BITMAP* newSource = destBMP; //Flip them.
8116
8117 909 BITMAP* subBmp = 0;
8118
8119 /* IDR what this was. -Z ( 17th April, 2019 )
8120 if ( bitmapIndex == -1 ) {
8121 blit(bmp, sourceBitmap, sx, sy, 0, 0, dw, dh);
8122 }
8123 */
8124
8125
2/4
✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 909 times.
909 if(rot != 0 || mode != 0)
8126 {
8127 subBmp = create_bitmap_ex(8,sourceBitmap->w, sourceBitmap->h);//script_drawing_commands.AquireSubBitmap(dw, dh);
8128 clear_bitmap(subBmp);
8129
8130 if(!subBmp)
8131 {
8132 Z_scripterrlog("bitmap->Blit failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation");
8133 return;
8134 }
8135 }
8136
8137
3/4
✓ Branch 0 taken 909 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 906 times.
909 if (sx + sw > destBMP->w || sy + sh > destBMP->h)
8138 {
8139 3 newSource = create_bitmap_ex(8, sw, sh);
8140 3 clear_bitmap(newSource);
8141 3 blit(destBMP, newSource, sx, sy, 0, 0, std::min(destBMP->w-sx, sw), std::min(destBMP->h-sy, sh));
8142 3 sx = 0;
8143 3 sy = 0;
8144 3 }
8145 //dx = dx + xoffset; //don't do this here!
8146 //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 )
8147
8148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 909 times.
909 if(stretched)
8149 {
8150 if(masked)
8151 { //stretched and masked
8152 if ( rot == 0 )
8153 { //if not rotated
8154 switch(mode)
8155 {
8156 case 1:
8157 //transparent
8158 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8159 draw_trans_sprite(newDest, subBmp, dx, dy);
8160 break;
8161
8162
8163 case 2:
8164 //pivot?
8165 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8166 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8167 //Pivoting requires two more args
8168 break;
8169
8170 case 3:
8171 //pivot + trans
8172 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8173 pivot_sprite_trans(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8174 break;
8175
8176 case 4:
8177 //flip v
8178 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8179 draw_sprite_v_flip(newDest, subBmp, dx, dy);
8180 break;
8181
8182 case 5:
8183 //trans + v flip
8184 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8185 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
8186 break;
8187
8188 case 6:
8189 //pivot + v flip
8190 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8191 pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8192 break;
8193
8194 case 8:
8195 //vlip h
8196 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8197 draw_sprite_h_flip(newDest, subBmp, dx, dy);
8198 break;
8199
8200 case 9:
8201 //trans + h flip
8202 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8203 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
8204 break;
8205
8206 case 10:
8207 //flip H and pivot
8208 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8209 //return error cannot pivot and h flip
8210 break;
8211
8212 case 12:
8213 //vh flip
8214 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8215 draw_sprite_vh_flip(newDest, subBmp, dx, dy);
8216 break;
8217
8218 case 13:
8219 //trans + vh flip
8220 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8221 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
8222 break;
8223
8224 case 14:
8225 //pivot and vh flip
8226 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8227 //return error cannot both pivot and vh flip
8228 break;
8229
8230 case 16:
8231 //lit
8232 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8233 draw_lit_sprite(newDest, subBmp, dx, dy, litcolour);
8234 break;
8235
8236 case 18:
8237 //pivot, lit
8238 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8239 pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8240 break;
8241
8242 case 20:
8243 //lit + v flip
8244 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8245 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
8246 break;
8247
8248 case 22:
8249 //Pivot, vflip, lit
8250 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8251 pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8252 break;
8253
8254 case 24:
8255 //lit + h flip
8256 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8257 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
8258 break;
8259
8260 case 26:
8261 //pivot + lit + hflip
8262 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
8263 //return error cannot pivot, lit, and flip
8264 break;
8265
8266 case 28:
8267 //lit + vh flip
8268 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8269 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
8270 break;
8271
8272 case 32: //gouraud
8273 //Probably not wort supporting.
8274 //masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8275 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8276 break;
8277
8278 case 0:
8279 //no effect
8280 masked_stretch_blit(newSource, newDest, sx, sy, sw, sh, dx, dy, dw, dh);
8281 break;
8282
8283
8284 default:
8285 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8286
8287
8288 }
8289 } //end if not rotated
8290
8291 if ( rot != 0 ) //if rotated
8292 {
8293 switch(mode)
8294 {
8295 case 1:
8296 //transparent
8297 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8298 rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8299
8300 break;
8301
8302 case 2:
8303 //pivot?
8304 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8305 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8306 //Pivoting requires two more args
8307 break;
8308
8309 case 3:
8310 //pivot + trans
8311 //return an error, cannot both rotate and pivot
8312 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8313 break;
8314
8315 case 4:
8316 //flip v
8317 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8318 rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8319 break;
8320
8321 case 5:
8322 //trans + v flip
8323 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8324 rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8325 break;
8326
8327 case 6:
8328 //pivot + v flip
8329 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8330 //return an error, cannot both rotate and pivot
8331 break;
8332
8333 case 8:
8334 //flip h
8335 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
8336 //return an error, cannot both rotate and flip H
8337 break;
8338
8339 case 9:
8340 //trans + h flip
8341 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
8342 //return an error, cannot rotate and flip a trans sprite
8343 break;
8344
8345 case 10:
8346 //flip H and pivot
8347 //return error cannot pivot and h flip
8348 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8349 break;
8350
8351 case 12:
8352 //vh flip
8353 //return an error, cannot rotate and VH flip a trans sprite
8354 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8355 break;
8356
8357 case 13:
8358 //trans + vh flip
8359 //return an error, cannot rotate and VH flip a trans sprite
8360 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8361 break;
8362
8363 case 14:
8364 //pivot and vh flip
8365 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8366 //return error cannot both pivot and vh flip
8367 break;
8368
8369 case 16:
8370 //lit
8371 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8372 rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8373 break;
8374
8375 case 18:
8376 //pivot, lit
8377 //return an error, cannot both rotate and pivot
8378 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8379 break;
8380
8381 case 20:
8382 //lit + vflip
8383 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8384 rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8385 break;
8386
8387 case 22:
8388 //Pivot, vflip, lit
8389 //return an error, cannot both rotate and pivot
8390 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8391 break;
8392
8393 case 24:
8394 //lit + h flip
8395 //return an error, cannot both rotate and H flip
8396 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
8397 break;
8398
8399 case 26:
8400 //pivot + lit + hflip
8401 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
8402 //return error cannot pivot, lit, and flip
8403 break;
8404
8405 case 28:
8406 //lit + vh flip
8407 //return an error, cannot both rotate and VH flip
8408 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8409 break;
8410
8411 case 32: //gouraud
8412 //Probably not wort supporting.
8413 //masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8414 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8415 break;
8416
8417 case 0:
8418 //no effect.
8419 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8420 rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8421 break;
8422
8423 default:
8424 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8425
8426 }
8427 }
8428 } //end if stretched and masked
8429
8430 else //stretched, not masked
8431 {
8432
8433
8434 if ( rot == 0 ) //if not rotated
8435 {
8436 switch(mode)
8437 {
8438 case 1:
8439 //transparent
8440 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8441 draw_trans_sprite(newDest, subBmp, dx, dy);
8442 break;
8443
8444
8445 case 2:
8446 //pivot?
8447 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8448 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8449 //Pivoting requires two more args
8450 break;
8451
8452 case 3:
8453 //pivot + trans
8454 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8455 pivot_sprite_trans(newDest, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot));
8456 break;
8457
8458 case 4:
8459 //flip v
8460 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8461 draw_sprite_v_flip(newDest, subBmp, dx, dy);
8462 break;
8463
8464 case 5:
8465 //trans + v flip
8466 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8467 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
8468 break;
8469
8470 case 6:
8471 //pivot + v flip
8472 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8473 pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8474 break;
8475
8476 case 8:
8477 //vlip h
8478 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8479 draw_sprite_h_flip(newDest, subBmp, dx, dy);
8480 break;
8481
8482 case 9:
8483 //trans + h flip
8484 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8485 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
8486 break;
8487
8488 case 10:
8489 //flip H and pivot
8490 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8491 //return error cannot pivot and h flip
8492 break;
8493
8494 case 12:
8495 //vh flip
8496 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8497 draw_sprite_vh_flip(newDest, subBmp, dx, dy);
8498 break;
8499
8500 case 13:
8501 //trans + vh flip
8502 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8503 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
8504 break;
8505
8506 case 14:
8507 //pivot and vh flip
8508 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8509 //return error cannot both pivot and vh flip
8510 break;
8511
8512 case 16:
8513 //lit
8514 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8515 draw_lit_sprite(newDest, subBmp, dx, dy, litcolour);
8516 break;
8517
8518 case 18:
8519 //pivot, lit
8520 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8521 pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8522 break;
8523
8524 case 20:
8525 //lit + v flip
8526 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8527 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
8528 break;
8529
8530 case 22:
8531 //Pivot, vflip, lit
8532 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8533 pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8534 break;
8535
8536 case 24:
8537 //lit + h flip
8538 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8539 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
8540 break;
8541
8542 case 26:
8543 //pivot + lit + hflip
8544 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
8545 //return error cannot pivot, lit, and flip
8546 break;
8547
8548 case 28:
8549 //lit + vh flip
8550 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8551 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
8552 break;
8553
8554 case 32: //gouraud
8555 //Probably not wort supporting.
8556 //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8557 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8558 break;
8559
8560 case 0:
8561 //no effect
8562 stretch_blit(newSource, newDest, sx, sy, sw, sh, dx, dy, dw, dh);
8563 break;
8564
8565
8566 default:
8567 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8568
8569
8570 }
8571 } //end if not rotated
8572
8573 if ( rot != 0 ) //if rotated
8574 {
8575 switch(mode)
8576 {
8577 case 1:
8578 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
8579 rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8580
8581 break;
8582
8583 case 2:
8584 //pivot?
8585 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8586 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8587 //Pivoting requires two more args
8588 break;
8589
8590 case 3:
8591 //pivot + trans
8592 //return an error, cannot both rotate and pivot
8593 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8594 break;
8595
8596 case 4:
8597 //flip v
8598 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8599 rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8600 break;
8601
8602 case 5:
8603 //trans + v flip
8604 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8605 rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8606 break;
8607
8608 case 6:
8609 //pivot + v flip
8610 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8611 //return an error, cannot both rotate and pivot
8612 break;
8613
8614 case 8:
8615 //flip h
8616 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
8617 //return an error, cannot both rotate and flip H
8618 break;
8619
8620 case 9:
8621 //trans + h flip
8622 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
8623 //return an error, cannot rotate and flip a trans sprite
8624 break;
8625
8626 case 10:
8627 //flip H and pivot
8628 //return error cannot pivot and h flip
8629 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8630 break;
8631
8632 case 12:
8633 //vh flip
8634 //return an error, cannot rotate and VH flip a trans sprite
8635 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8636 break;
8637
8638 case 13:
8639 //trans + vh flip
8640 //return an error, cannot rotate and VH flip a trans sprite
8641 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8642 break;
8643
8644 case 14:
8645 //pivot and vh flip
8646 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8647 //return error cannot both pivot and vh flip
8648 break;
8649
8650 case 16:
8651 //lit
8652 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
8653 rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8654 break;
8655
8656 case 18:
8657 //pivot, lit
8658 //return an error, cannot both rotate and pivot
8659 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8660 break;
8661
8662 case 20:
8663 //lit + vflip
8664 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
8665 rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8666 break;
8667
8668 case 22:
8669 //Pivot, vflip, lit
8670 //return an error, cannot both rotate and pivot
8671 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8672 break;
8673
8674 case 24:
8675 //lit + h flip
8676 //return an error, cannot both rotate and H flip
8677 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
8678 break;
8679
8680 case 26:
8681 //pivot + lit + hflip
8682 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
8683 //return error cannot pivot, lit, and flip
8684 break;
8685
8686 case 28:
8687 //lit + vh flip
8688 //return an error, cannot both rotate and VH flip
8689 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8690 break;
8691
8692 case 32: //gouraud
8693 //Probably not wort supporting.
8694 //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8695 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8696 break;
8697
8698 case 0:
8699 //no effect.
8700 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8701 rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8702 break;
8703
8704 default:
8705 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8706
8707 }
8708 }
8709
8710 } //end if stretched, but not masked
8711 }
8712 else //not stretched
8713 {
8714
8715
2/2
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 3 times.
909 if(masked) //if masked, but not stretched
8716 {
8717
8718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if ( rot == 0 ) //if not rotated
8719 {
8720
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 906 times.
906 switch(mode)
8721 {
8722 case 1:
8723 //transparent
8724 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8725 draw_trans_sprite(newDest, subBmp, dx, dy);
8726 break;
8727
8728
8729 case 2:
8730 //pivot?
8731 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8732 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8733 //Pivoting requires two more args
8734 break;
8735
8736 case 3:
8737 //pivot + trans
8738 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8739 pivot_sprite_trans(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8740 break;
8741
8742 case 4:
8743 //flip v
8744 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8745 draw_sprite_v_flip(newDest, subBmp, dx, dy);
8746 break;
8747
8748 case 5:
8749 //trans + v flip
8750 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8751 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
8752 break;
8753
8754 case 6:
8755 //pivot + v flip
8756 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8757 pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8758 break;
8759
8760 case 8:
8761 //vlip h
8762 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8763 draw_sprite_h_flip(newDest, subBmp, dx, dy);
8764 break;
8765
8766 case 9:
8767 //trans + h flip
8768 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8769 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
8770 break;
8771
8772 case 10:
8773 //flip H and pivot
8774 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8775 //return error cannot pivot and h flip
8776 break;
8777
8778 case 12:
8779 //vh flip
8780 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8781 draw_sprite_vh_flip(newDest, subBmp, dx, dy);
8782 break;
8783
8784 case 13:
8785 //trans + vh flip
8786 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8787 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
8788 break;
8789
8790 case 14:
8791 //pivot and vh flip
8792 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8793 //return error cannot both pivot and vh flip
8794 break;
8795
8796 case 16:
8797 //lit
8798 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8799 draw_lit_sprite(newDest, subBmp, dx, dy, litcolour);
8800 break;
8801
8802 case 18:
8803 //pivot, lit
8804 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8805 pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8806 break;
8807
8808 case 20:
8809 //lit + v flip
8810 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8811 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
8812 break;
8813
8814 case 22:
8815 //Pivot, vflip, lit
8816 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8817 pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8818 break;
8819
8820 case 24:
8821 //lit + h flip
8822 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8823 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
8824 break;
8825
8826 case 26:
8827 //pivot + lit + hflip
8828 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
8829 //return error cannot pivot, lit, and flip
8830 break;
8831
8832 case 28:
8833 //lit + vh flip
8834 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8835 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
8836 break;
8837
8838 case 32: //gouraud
8839 //Probably not wort supporting.
8840 //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8841 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8842 break;
8843
8844 case 0:
8845 //no effect
8846 906 masked_blit(newSource, newDest, sx, sy, dx, dy, dw, dh);
8847 906 break;
8848
8849
8850 default:
8851 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8852
8853
8854 }
8855 906 } //end if not rotated
8856
8857
1/2
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
906 if ( rot != 0 ) //if rotated
8858 {
8859 switch(mode)
8860 {
8861 case 1:
8862 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); //transparent
8863 rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8864
8865 break;
8866
8867 case 2:
8868 //pivot?
8869 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8870 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8871 //Pivoting requires two more args
8872 break;
8873
8874 case 3:
8875 //pivot + trans
8876 //return an error, cannot both rotate and pivot
8877 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8878 break;
8879
8880 case 4:
8881 //flip v
8882 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8883 rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8884 break;
8885
8886 case 5:
8887 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip
8888 rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8889 break;
8890
8891 case 6:
8892 //pivot + v flip
8893 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8894 //return an error, cannot both rotate and pivot
8895 break;
8896
8897 case 8:
8898 //flip h
8899 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
8900 //return an error, cannot both rotate and flip H
8901 break;
8902
8903 case 9:
8904 //trans + h flip
8905 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
8906 //return an error, cannot rotate and flip a trans sprite
8907 break;
8908
8909 case 10:
8910 //flip H and pivot
8911 //return error cannot pivot and h flip
8912 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8913 break;
8914
8915 case 12:
8916 //vh flip
8917 //return an error, cannot rotate and VH flip a trans sprite
8918 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8919 break;
8920
8921 case 13:
8922 //trans + vh flip
8923 //return an error, cannot rotate and VH flip a trans sprite
8924 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8925 break;
8926
8927 case 14:
8928 //pivot and vh flip
8929 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8930 //return error cannot both pivot and vh flip
8931 break;
8932
8933 case 16:
8934 //lit
8935 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8936 rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8937 break;
8938
8939 case 18:
8940 //pivot, lit
8941 //return an error, cannot both rotate and pivot
8942 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8943 break;
8944
8945 case 20:
8946 //lit + vflip
8947 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8948 rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8949 break;
8950
8951 case 22:
8952 //Pivot, vflip, lit
8953 //return an error, cannot both rotate and pivot
8954 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8955 break;
8956
8957 case 24:
8958 //lit + h flip
8959 //return an error, cannot both rotate and H flip
8960 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
8961 break;
8962
8963 case 26:
8964 //pivot + lit + hflip
8965 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
8966 //return error cannot pivot, lit, and flip
8967 break;
8968
8969 case 28:
8970 //lit + vh flip
8971 //return an error, cannot both rotate and VH flip
8972 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8973 break;
8974
8975 case 32: //gouraud
8976 //Probably not wort supporting.
8977 //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8978 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8979 break;
8980
8981 case 0:
8982 //no effect.
8983 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8984 rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8985 break;
8986
8987 default:
8988 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8989
8990 }
8991 } //end rtated, masked
8992 906 } //end if masked
8993
8994 else //not masked, and not stretched; just blit
8995 {
8996
8997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( rot == 0 ) //if not rotated
8998 {
8999
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 3 times.
3 switch(mode)
9000 {
9001 case 1:
9002 //transparent
9003 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9004 draw_trans_sprite(newDest, subBmp, dx, dy);
9005 break;
9006
9007
9008 case 2:
9009 //pivot?
9010 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9011 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9012 //Pivoting requires two more args
9013 break;
9014
9015 case 3:
9016 //pivot + trans
9017 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9018 pivot_sprite_trans(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9019 break;
9020
9021 case 4:
9022 //flip v
9023 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9024 draw_sprite_v_flip(newDest, subBmp, dx, dy);
9025 break;
9026
9027 case 5:
9028 //trans + v flip
9029 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9030 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
9031 break;
9032
9033 case 6:
9034 //pivot + v flip
9035 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9036 pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9037 break;
9038
9039 case 8:
9040 //vlip h
9041 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9042 draw_sprite_h_flip(newDest, subBmp, dx, dy);
9043 break;
9044
9045 case 9:
9046 //trans + h flip
9047 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9048 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
9049 break;
9050
9051 case 10:
9052 //flip H and pivot
9053 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
9054 //return error cannot pivot and h flip
9055 break;
9056
9057 case 12:
9058 //vh flip
9059 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9060 draw_sprite_vh_flip(newDest, subBmp, dx, dy);
9061 break;
9062
9063 case 13:
9064 //trans + vh flip
9065 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9066 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
9067 break;
9068
9069 case 14:
9070 //pivot and vh flip
9071 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
9072 //return error cannot both pivot and vh flip
9073 break;
9074
9075 case 16:
9076 //lit
9077 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9078 draw_lit_sprite(newDest, subBmp, dx, dy, litcolour);
9079 break;
9080
9081 case 18:
9082 //pivot, lit
9083 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9084 pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9085 break;
9086
9087 case 20:
9088 //lit + v flip
9089 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9090 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
9091 break;
9092
9093 case 22:
9094 //Pivot, vflip, lit
9095 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9096 pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9097 break;
9098
9099 case 24:
9100 //lit + h flip
9101 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9102 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
9103 break;
9104
9105 case 26:
9106 //pivot + lit + hflip
9107 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
9108 //return error cannot pivot, lit, and flip
9109 break;
9110
9111 case 28:
9112 //lit + vh flip
9113 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9114 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
9115 break;
9116
9117 case 32: //gouraud
9118 //Probably not wort supporting.
9119 //blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9120 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9121 break;
9122
9123 case 0:
9124 //no effect
9125 3 blit(newSource, newDest, sx, sy, dx, dy, dw, dh);
9126 3 break;
9127
9128
9129 default:
9130 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
9131
9132
9133 }
9134 3 } //end if not rotated
9135
9136
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if ( rot != 0 ) //if rotated
9137 {
9138 switch(mode)
9139 {
9140 case 1:
9141 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);//transparent
9142 rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
9143
9144 break;
9145
9146 case 2:
9147 //pivot?
9148 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9149 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9150 //Pivoting requires two more args
9151 break;
9152
9153 case 3:
9154 //pivot + trans
9155 //return an error, cannot both rotate and pivot
9156 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
9157 break;
9158
9159 case 4:
9160 //flip v
9161 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9162 rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
9163 break;
9164
9165 case 5:
9166 //trans + v flip
9167 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9168 rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
9169 break;
9170
9171 case 6:
9172 //pivot + v flip
9173 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
9174 //return an error, cannot both rotate and pivot
9175 break;
9176
9177 case 8:
9178 //flip h
9179 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
9180 //return an error, cannot both rotate and flip H
9181 break;
9182
9183 case 9:
9184 //trans + h flip
9185 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
9186 //return an error, cannot rotate and flip a trans sprite
9187 break;
9188
9189 case 10:
9190 //flip H and pivot
9191 //return error cannot pivot and h flip
9192 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
9193 break;
9194
9195 case 12:
9196 //vh flip
9197 //return an error, cannot rotate and VH flip a trans sprite
9198 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
9199 break;
9200
9201 case 13:
9202 //trans + vh flip
9203 //return an error, cannot rotate and VH flip a trans sprite
9204 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
9205 break;
9206
9207 case 14:
9208 //pivot and vh flip
9209 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
9210 //return error cannot both pivot and vh flip
9211 break;
9212
9213 case 16:
9214 //lit
9215 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9216 rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9217 break;
9218
9219 case 18:
9220 //pivot, lit
9221 //return an error, cannot both rotate and pivot
9222 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
9223 break;
9224
9225 case 20:
9226 //lit + vflip
9227 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9228 rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9229 break;
9230
9231 case 22:
9232 //Pivot, vflip, lit
9233 //return an error, cannot both rotate and pivot
9234 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
9235 break;
9236
9237 case 24:
9238 //lit + h flip
9239 //return an error, cannot both rotate and H flip
9240 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
9241 break;
9242
9243 case 26:
9244 //pivot + lit + hflip
9245 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
9246 //return error cannot pivot, lit, and flip
9247 break;
9248
9249 case 28:
9250 //lit + vh flip
9251 //return an error, cannot both rotate and VH flip
9252 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
9253 break;
9254
9255 case 32: //gouraud
9256 //Probably not wort supporting.
9257 //blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9258 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9259 break;
9260
9261 case 0:
9262 //no effect.
9263 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9264 rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
9265 break;
9266
9267 default:
9268 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
9269
9270 }
9271 } //end if rotated
9272 } //end if not masked
9273 } //end if not stretched
9274
9275 //cleanup
9276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 909 times.
909 if(subBmp)
9277 {
9278 //script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap.
9279 destroy_bitmap(subBmp);
9280 }
9281
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 906 times.
909 if(newSource != destBMP)
9282 {
9283 3 destroy_bitmap(newSource);
9284 3 }
9285 909 }
9286
9287
9288 void bmp_do_drawquad3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
9289 {
9290
9291 //sdci[1]=layer
9292 //sdci[2]=pos[12]
9293 //sdci[3]=uv[8]
9294 //sdci[4]=color[4]
9295 //sdci[5]=size[2]
9296 //sdci[6]=flip
9297 //sdci[7]=tile/combo
9298 //sdci[8]=polytype
9299 //sdci[9] = other bitmap as texture
9300 //sdci[17] Bitmap Pointer
9301 if ( sdci[17] <= 0 )
9302 {
9303 Z_scripterrlog("bitmap->Quad3D() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
9304 return;
9305 }
9306 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
9307 if ( refbmp == NULL ) return;
9308
9309 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
9310
9311 if(!v_ptr)
9312 {
9313 al_trace("Quad3d: Vector pointer is null! Internal error. \n");
9314 return;
9315 }
9316
9317 std::vector<int32_t> &v = *v_ptr;
9318
9319 if(v.empty())
9320 return;
9321
9322 int32_t* pos = &v[0];
9323 int32_t* uv = &v[12];
9324 int32_t* col = &v[20];
9325 int32_t* size = &v[24];
9326
9327 int32_t w = size[0]; //magic numerical constants... yuck.
9328 int32_t h = size[1];
9329 int32_t flip = (sdci[6]/10000)&3;
9330 int32_t tile = sdci[7]/10000;
9331 int32_t polytype = sdci[8]/10000;
9332 int32_t quad_render_source = sdci[9]-10;
9333 Z_scripterrlog("Quad3D texture is %d\n", quad_render_source);
9334
9335 polytype = vbound(polytype, 0, 14);
9336
9337 int32_t tex_width = w*16;
9338 int32_t tex_height = h*16;
9339
9340 bool mustDestroyBmp = false;
9341 BITMAP *tex=NULL;
9342
9343
9344 bool tex_is_bitmap = ( sdci[9] != 0 );
9345 //Z_scripterrlog("sdci[9] is %d\n", quad_render_source);
9346 //Z_scripterrlog("sdci[17] is %d\n", sdci[17]-10);
9347 BITMAP *bmptexture;
9348
9349 if ( tex_is_bitmap ) bmptexture = FFCore.GetScriptBitmap(quad_render_source);
9350
9351 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
9352
9353
9354 if ( !tex_is_bitmap )
9355 {
9356 tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
9357
9358 if(!tex)
9359 {
9360 mustDestroyBmp = true;
9361 tex = create_bitmap_ex(8, tex_width, tex_height);
9362 clear_bitmap(tex);
9363 }
9364 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
9365 {
9366 Z_message("Quad3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
9367 return; //non power of two error
9368 }
9369 if(tile > 0) // TILE
9370 {
9371 TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
9372 }
9373 else // COMBO
9374 {
9375 const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ];
9376 const int32_t tiletodraw = combo_tile(c, 0, 0);
9377 flip = flip ^ c.flip;
9378
9379 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
9380 }
9381
9382 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
9383 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
9384 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
9385 V3D_f V4 = { static_cast<float>(pos[9]+xoffset), static_cast<float>(pos[10]+yoffset), static_cast<float>(pos[11]), static_cast<float>(uv[6]), static_cast<float>(uv[7]), col[3] };
9386
9387 quad3d_f(refbmp, polytype, tex, &V1, &V2, &V3, &V4);
9388 if(mustDestroyBmp)
9389 destroy_bitmap(tex);
9390 }
9391 else
9392 {
9393
9394 if ( !bmptexture )
9395 {
9396 Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Quad3D()");
9397 tex_is_bitmap = 0;
9398 return;
9399 }
9400 if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
9401 if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
9402 if ( !isPowerOfTwo(h) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", h);
9403 if ( !isPowerOfTwo(w) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", w);
9404
9405 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
9406 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
9407 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
9408 V3D_f V4 = { static_cast<float>(pos[9]+xoffset), static_cast<float>(pos[10]+yoffset), static_cast<float>(pos[11]), static_cast<float>(uv[6]), static_cast<float>(uv[7]), col[3] };
9409
9410 BITMAP *foo = create_bitmap_ex(8, 256, 176);
9411
9412 //quad3d_f(refbmp, polytype, foo, &V1, &V2, &V3, &V4);
9413 quad3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3, &V4);
9414 destroy_bitmap(foo);
9415
9416 }
9417
9418
9419
9420 }
9421
9422
9423
9424 void bmp_do_drawtriangle3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
9425 {
9426 //sdci[1]=layer
9427 //sdci[2]=pos[9]
9428 //sdci[3]=uv[6]
9429 //sdci[4]=color[3]
9430 //sdci[5]=size[2]
9431 //sdci[6]=flip
9432 //sdci[7]=tile/combo
9433 //sdci[8]=polytype
9434 //sdci[9] bitmap as texture
9435 //sdci[17] Bitmap Pointer
9436 if ( sdci[17] <= 0 )
9437 {
9438 Z_scripterrlog("bitmap->Triangle3D() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]);
9439 return;
9440 }
9441 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
9442 if ( refbmp == NULL ) return;
9443
9444 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
9445
9446 if(!v_ptr)
9447 {
9448 al_trace("bitmap->Triangle3d: Vector pointer is null! Internal error. \n");
9449 return;
9450 }
9451
9452 std::vector<int32_t> &v = *v_ptr;
9453
9454 if(v.empty())
9455 return;
9456
9457 int32_t* pos = &v[0];
9458 int32_t* uv = &v[9];
9459 int32_t* col = &v[15];
9460 int32_t* size = &v[18];
9461
9462 int32_t w = size[0]; //magic numerical constants... yuck.
9463 int32_t h = size[1];
9464 int32_t flip = (sdci[6]/10000)&3;
9465 int32_t tile = sdci[7]/10000;
9466 int32_t polytype = sdci[8]/10000;
9467 int32_t quad_render_source = sdci[9]-10;
9468 polytype = vbound(polytype, 0, 14);
9469
9470 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
9471 {
9472 Z_message("bitmap->Triangle3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
9473 return; //non power of two error
9474 }
9475
9476 int32_t tex_width = w*16;
9477 int32_t tex_height = h*16;
9478
9479 bool mustDestroyBmp = false;
9480 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
9481
9482 if(!tex)
9483 {
9484 mustDestroyBmp = true;
9485 tex = create_bitmap_ex(8, tex_width, tex_height);
9486 clear_bitmap(tex);
9487 }
9488
9489 bool tex_is_bitmap = ( sdci[9] != 0 );
9490 BITMAP *bmptexture=NULL;
9491 if ( tex_is_bitmap )
9492 {
9493 bmptexture = FFCore.GetScriptBitmap(quad_render_source);
9494 if ( !bmptexture )
9495 {
9496 Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Triangle3()");
9497 tex_is_bitmap = 0;
9498 }
9499 }
9500
9501 if ( !tex_is_bitmap )
9502 {
9503 if(tile > 0) // TILE
9504 {
9505 TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
9506 }
9507 else // COMBO
9508 {
9509 const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ];
9510 const int32_t tiletodraw = combo_tile(c, 0, 0);
9511 flip = flip ^ c.flip;
9512
9513 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
9514 }
9515
9516 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
9517 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
9518 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
9519
9520 triangle3d_f(refbmp, polytype, tex, &V1, &V2, &V3);
9521 }
9522 else
9523 {
9524 if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
9525 if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
9526 if ( !isPowerOfTwo(w) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", w);
9527 if ( !isPowerOfTwo(h) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", h);
9528
9529 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
9530 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
9531 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
9532
9533 triangle3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3);
9534
9535
9536 }
9537 if(mustDestroyBmp)
9538 destroy_bitmap(tex);
9539
9540 }
9541
9542
9543 bool is_layer_transparent(const mapscr& m, int32_t layer)
9544 {
9545 layer = vbound(layer, 0, 5);
9546 return m.layeropacity[layer] == 128;
9547 }
9548
9549 4328553 mapscr *getmapscreen(int32_t map_index, int32_t screen_index, int32_t layer) //returns NULL for invalid or non-existent layer
9550 {
9551 mapscr *base_screen;
9552 4328553 int32_t index = map_index*MAPSCRS+screen_index;
9553
9554
2/4
✓ Branch 0 taken 4328553 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4328553 times.
4328553 if((uint32_t)layer > 6 || (uint32_t)index >= TheMaps.size())
9555 return NULL;
9556
9557
2/2
✓ Branch 0 taken 3543647 times.
✓ Branch 1 taken 784906 times.
4328553 if(layer != 0)
9558 {
9559 784906 layer = layer - 1;
9560
9561 784906 base_screen=&(TheMaps[index]);
9562
9563
2/2
✓ Branch 0 taken 748179 times.
✓ Branch 1 taken 36727 times.
784906 if(base_screen->layermap[layer]==0)
9564 36727 return NULL;
9565
9566 748179 index=(base_screen->layermap[layer]-1)*MAPSCRS+base_screen->layerscreen[layer];
9567
9568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 748179 times.
748179 if((uint32_t)index >= TheMaps.size()) // Might as well make sure
9569 return NULL;
9570 748179 }
9571
9572 4291826 return &(TheMaps[index]);
9573 4328553 }
9574
9575 191257 void draw_mapscr(BITMAP *b, const mapscr& m, int32_t x, int32_t y, bool transparent)
9576 {
9577
2/2
✓ Branch 0 taken 33661232 times.
✓ Branch 1 taken 191257 times.
33852489 for(int32_t i(0); i < 176; ++i)
9578 {
9579 33661232 const int32_t x2 = ((i&15)<<4) + x;
9580 33661232 const int32_t y2 = (i&0xF0) + y;
9581
9582 //const newcombo & c = combobuf[ m.data[i] ];
9583 /*
9584 newcombo c = combobuf[m.data[i]];
9585 int32_t csets[4];
9586 int32_t cofs = c.csets&15;
9587
9588 if(cofs&8)
9589 cofs |= ~int32_t(0xF);
9590
9591 for(int32_t i=0; i<4; ++i)
9592 csets[i] = c.csets&(16<<i) ? cset + cofs : cset;
9593
9594
9595 const int32_t tile = combo_tile(c, x2, y2);
9596 */
9597
9598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33661232 times.
33661232 if(transparent)
9599 {
9600 //void overcomboblocktranslucent(BITMAP *dest, int32_t x, int32_t y, int32_t cmbdat, int32_t cset, int32_t w, int32_t h, int32_t opacity)
9601 overcomboblocktranslucent(b, x2, y2, m.data[i], m.cset[i], 1, 1, 128);
9602 //overtiletranslucent16(b, tile, x2, y2, m.cset[i], c.flip, 128);
9603 }
9604 else
9605 {
9606 //overcomboblock(BITMAP *dest, int32_t x, int32_t y, int32_t cmbdat, int32_t cset, int32_t w, int32_t h)
9607 33661232 overcomboblock(b, x2, y2, m.data[i], m.cset[i], 1, 1);
9608 //overtile16(b, tile, x2, y2, m.cset[i], c.flip);
9609 }
9610 33661232 }
9611 191257 }
9612
9613 void draw_map_solidity(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
9614 {
9615 BITMAP* square = create_bitmap_ex(8,16,16);
9616
9617 for(int32_t i(0); i < 176; ++i)
9618 {
9619 const int32_t x2 = ((i&15)<<4) + x;
9620 const int32_t y2 = (i&0xF0) + y;
9621 //Blit the palette index of the solidity value.
9622 //int32_t col = (combobuf[m.data[i]].walk&15);
9623 //if ( col != 0 )
9624 //{
9625 // Z_scripterrlog("Position %d has a solidity value of %d.\n", i, col);
9626 //
9627 //}
9628 clear_to_color(square,(combobuf[m.data[i]].walk&15));
9629 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
9630 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
9631 }
9632 destroy_bitmap(square);
9633 }
9634
9635 void do_bmpdrawscreen_solidmaskr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
9636 {
9637 //sdci[1]=layer
9638 //sdci[2]=map
9639 //sdci[3]=screen
9640 //sdci[4]=x
9641 //sdci[5]=y
9642 //sdci[6]=rotation
9643 //sdci[17] Bitmap Pointer
9644
9645 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
9646 if ( refbmp == NULL ) return;
9647
9648 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
9649
9650 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
9651 int32_t scrn = sdci[3]/10000;
9652 int32_t x = sdci[4]/10000;
9653 int32_t y = sdci[5]/10000;
9654 int32_t x1 = x + xoffset;
9655 int32_t y1 = y + yoffset;
9656 int32_t rotation = sdci[6]/10000;
9657
9658 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
9659
9660 if(index >= TheMaps.size())
9661 {
9662 al_trace("DrawScreen: invalid map or screen index. \n");
9663 return;
9664 }
9665
9666 const mapscr & m = TheMaps[index];
9667
9668
9669 BITMAP* b = FFCore.GetScriptBitmap(sdci[17]-10);
9670 if ( refbmp == NULL ) return;
9671
9672 if(rotation != 0)
9673 b = script_drawing_commands.AquireSubBitmap(256, 176);
9674
9675 //draw layer 0
9676 draw_map_solidity(b, m, x1, y1);
9677 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS))
9678 {
9679 for(int32_t i(0); i < 6; ++i)
9680 {
9681 if(m.layermap[i] == 0) continue;
9682
9683 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
9684
9685 if(layer_screen_index >= TheMaps.size())
9686 continue;
9687
9688 //draw valid layers
9689 draw_map_solidity(b, TheMaps[ layer_screen_index ], x1, y1);
9690 }
9691 }
9692
9693 if(rotation != 0) // rotate
9694 {
9695 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
9696 script_drawing_commands.ReleaseSubBitmap(b);
9697 }
9698 }
9699
9700 void draw_map_solid(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
9701 {
9702 BITMAP* square = create_bitmap_ex(8,16,16);
9703 BITMAP* subsquare = create_bitmap_ex(8,16,16);
9704 clear_to_color(subsquare,1);
9705
9706 for(int32_t i(0); i < 176; ++i)
9707 {
9708 const int32_t x2 = ((i&15)<<4) + x;
9709 const int32_t y2 = (i&0xF0) + y;
9710 //Blit the palette index of the solidity value.
9711 //int32_t col = (combobuf[m.data[i]].walk&15);
9712 //if ( col != 0 )
9713 //{
9714 // Z_scripterrlog("Position %d has a solidity value of %d.\n", i, col);
9715 //
9716 //}
9717 clear_bitmap(square);
9718 int32_t sol = (combobuf[m.data[i]].walk);
9719 //al_trace("Solidity is: %d.\n", sol);
9720 if ( sol & 1 )
9721 {
9722 blit(subsquare, square, 0, 0, 0, 0, 8, 8);
9723 }
9724 if ( sol & 2 )
9725 {
9726 blit(subsquare, square, 0, 0, 0, 8, 8, 8);
9727 }
9728 if ( sol & 4 )
9729 {
9730 blit(subsquare, square, 0, 0, 8, 0, 8, 8);
9731 }
9732 if ( sol &8 ) {
9733 blit(subsquare, square, 0, 0, 8, 8, 8, 8);
9734 }
9735
9736 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
9737 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
9738 }
9739 destroy_bitmap(square);
9740 destroy_bitmap(subsquare);
9741 }
9742
9743 void do_bmpdrawscreen_solidr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
9744 {
9745 //sdci[1]=layer
9746 //sdci[2]=map
9747 //sdci[3]=screen
9748 //sdci[4]=x
9749 //sdci[5]=y
9750 //sdci[6]=rotation
9751 //sdci[17] Bitmap Pointer
9752
9753 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
9754 if ( refbmp == NULL ) return;
9755
9756 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
9757
9758 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
9759 int32_t scrn = sdci[3]/10000;
9760 int32_t x = sdci[4]/10000;
9761 int32_t y = sdci[5]/10000;
9762 int32_t x1 = x + xoffset;
9763 int32_t y1 = y + yoffset;
9764 int32_t rotation = sdci[6]/10000;
9765
9766 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
9767
9768 if(index >= TheMaps.size())
9769 {
9770 al_trace("DrawScreen: invalid map or screen index. \n");
9771 return;
9772 }
9773
9774 const mapscr & m = TheMaps[index];
9775
9776
9777 BITMAP* b = FFCore.GetScriptBitmap(sdci[17]-10);
9778 if ( refbmp == NULL ) return;
9779
9780 if(rotation != 0)
9781 b = script_drawing_commands.AquireSubBitmap(256, 176);
9782
9783 //draw layer 0
9784 draw_map_solid(b, m, x1, y1);
9785
9786 for(int32_t i(0); i < 6; ++i) //This one doesn't need the QR; it works just fine.
9787 {
9788 if(m.layermap[i] == 0) continue;
9789
9790 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
9791
9792 if(layer_screen_index >= TheMaps.size())
9793 continue;
9794
9795 //draw valid layers
9796 draw_map_solid(b, TheMaps[ layer_screen_index ], x1, y1);
9797 }
9798
9799 if(rotation != 0) // rotate
9800 {
9801 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
9802 script_drawing_commands.ReleaseSubBitmap(b);
9803 }
9804 }
9805
9806 1024 void draw_map_cflag(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
9807 {
9808 1024 BITMAP* square = create_bitmap_ex(8,16,16);
9809
9810
2/2
✓ Branch 0 taken 180224 times.
✓ Branch 1 taken 1024 times.
181248 for(int32_t i(0); i < 176; ++i)
9811 {
9812 180224 const int32_t x2 = ((i&15)<<4) + x;
9813 180224 const int32_t y2 = (i&0xF0) + y;
9814 //Blit the palette index of the solidity value.
9815 180224 clear_to_color(square,m.sflag[i]);
9816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180224 times.
180224 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
9817 180224 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
9818 180224 }
9819 1024 destroy_bitmap(square);
9820 1024 }
9821
9822 1024 void do_bmpdrawscreen_cflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
9823 {
9824 //sdci[1]=layer
9825 //sdci[2]=map
9826 //sdci[3]=screen
9827 //sdci[4]=x
9828 //sdci[5]=y
9829 //sdci[6]=rotation
9830 //sdci[17] Bitmap Pointer
9831
9832 1024 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
9833
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if ( refbmp == NULL ) return;
9834
9835
2/4
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1024 times.
✗ Branch 3 not taken.
1024 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
9836
9837 1024 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
9838 1024 int32_t scrn = sdci[3]/10000;
9839 1024 int32_t x = sdci[4]/10000;
9840 1024 int32_t y = sdci[5]/10000;
9841 1024 int32_t x1 = x + xoffset;
9842 1024 int32_t y1 = y + yoffset;
9843 1024 int32_t rotation = sdci[6]/10000;
9844
9845 1024 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
9846
9847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 if(index >= TheMaps.size())
9848 {
9849 al_trace("DrawScreen: invalid map or screen index. \n");
9850 return;
9851 }
9852
9853 1024 const mapscr & m = TheMaps[index];
9854
9855
9856 1024 BITMAP* b = FFCore.GetScriptBitmap(sdci[17]-10);
9857
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if ( refbmp == NULL ) return;
9858
9859
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(rotation != 0)
9860 b = script_drawing_commands.AquireSubBitmap(256, 176);
9861
9862 //draw layer 0
9863 1024 draw_map_cflag(b, m, x1, y1);
9864
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS))
9865 {
9866 for(int32_t i(0); i < 6; ++i)
9867 {
9868 if(m.layermap[i] == 0) continue;
9869
9870 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
9871
9872 if(layer_screen_index >= TheMaps.size())
9873 continue;
9874
9875 //draw valid layers
9876 draw_map_cflag(b, TheMaps[ layer_screen_index ], x1, y1);
9877 }
9878 }
9879
9880
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(rotation != 0) // rotate
9881 {
9882 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
9883 script_drawing_commands.ReleaseSubBitmap(b);
9884 }
9885 1024 }
9886
9887
9888 void draw_map_combotype(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
9889 {
9890 BITMAP* square = create_bitmap_ex(8,16,16);
9891
9892 for(int32_t i(0); i < 176; ++i)
9893 {
9894 const int32_t x2 = ((i&15)<<4) + x;
9895 const int32_t y2 = (i&0xF0) + y;
9896 //Blit the palette index of the solidity value.
9897 clear_to_color(square,(combobuf[m.data[i]].type));
9898 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
9899 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
9900 }
9901 destroy_bitmap(square);
9902 }
9903
9904 void do_bmpdrawscreen_ctyper(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
9905 {
9906 //sdci[1]=layer
9907 //sdci[2]=map
9908 //sdci[3]=screen
9909 //sdci[4]=x
9910 //sdci[5]=y
9911 //sdci[6]=rotation
9912 //sdci[17] Bitmap Pointer
9913
9914 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
9915 if ( refbmp == NULL ) return;
9916
9917 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
9918
9919 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
9920 int32_t scrn = sdci[3]/10000;
9921 int32_t x = sdci[4]/10000;
9922 int32_t y = sdci[5]/10000;
9923 int32_t x1 = x + xoffset;
9924 int32_t y1 = y + yoffset;
9925 int32_t rotation = sdci[6]/10000;
9926
9927 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
9928
9929 if(index >= TheMaps.size())
9930 {
9931 al_trace("DrawScreen: invalid map or screen index. \n");
9932 return;
9933 }
9934
9935 const mapscr & m = TheMaps[index];
9936
9937
9938 BITMAP* b = FFCore.GetScriptBitmap(sdci[17]-10);
9939 if ( refbmp == NULL ) return;
9940
9941 if(rotation != 0)
9942 b = script_drawing_commands.AquireSubBitmap(256, 176);
9943
9944 //draw layer 0
9945 draw_map_combotype(b, m, x1, y1);
9946
9947 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS))
9948 {
9949 for(int32_t i(0); i < 6; ++i)
9950 {
9951 if(m.layermap[i] == 0) continue;
9952
9953 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
9954
9955 if(layer_screen_index >= TheMaps.size())
9956 continue;
9957
9958 //draw valid layers
9959 draw_map_combotype(b, TheMaps[ layer_screen_index ], x1, y1);
9960 }
9961 }
9962
9963 if(rotation != 0) // rotate
9964 {
9965 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
9966 script_drawing_commands.ReleaseSubBitmap(b);
9967 }
9968 }
9969
9970
9971 void draw_map_comboiflag(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
9972 {
9973 BITMAP* square = create_bitmap_ex(8,16,16);
9974
9975 for(int32_t i(0); i < 176; ++i)
9976 {
9977 const int32_t x2 = ((i&15)<<4) + x;
9978 const int32_t y2 = (i&0xF0) + y;
9979 //Blit the palette index of the solidity value.
9980 clear_to_color(square,(combobuf[m.data[i]].flag));
9981 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
9982 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
9983 }
9984 destroy_bitmap(square);
9985 }
9986
9987 void do_bmpdrawscreen_ciflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
9988 {
9989 //sdci[1]=layer
9990 //sdci[2]=map
9991 //sdci[3]=screen
9992 //sdci[4]=x
9993 //sdci[5]=y
9994 //sdci[6]=rotation
9995 //sdci[17] Bitmap Pointer
9996
9997 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
9998 if ( refbmp == NULL ) return;
9999
10000 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
10001
10002 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10003 int32_t scrn = sdci[3]/10000;
10004 int32_t x = sdci[4]/10000;
10005 int32_t y = sdci[5]/10000;
10006 int32_t x1 = x + xoffset;
10007 int32_t y1 = y + yoffset;
10008 int32_t rotation = sdci[6]/10000;
10009
10010 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
10011
10012 if(index >= TheMaps.size())
10013 {
10014 al_trace("DrawScreen: invalid map or screen index. \n");
10015 return;
10016 }
10017
10018 const mapscr & m = TheMaps[index];
10019
10020
10021 BITMAP* b = FFCore.GetScriptBitmap(sdci[17]-10);
10022 if ( refbmp == NULL ) return;
10023
10024 if(rotation != 0)
10025 b = script_drawing_commands.AquireSubBitmap(256, 176);
10026
10027 //draw layer 0
10028 draw_map_comboiflag(b, m, x1, y1);
10029
10030 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS))
10031 {
10032 for(int32_t i(0); i < 6; ++i)
10033 {
10034 if(m.layermap[i] == 0) continue;
10035
10036 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
10037
10038 if(layer_screen_index >= TheMaps.size())
10039 continue;
10040
10041 //draw valid layers
10042 draw_map_comboiflag(b, TheMaps[ layer_screen_index ], x1, y1);
10043 }
10044 }
10045
10046 if(rotation != 0) // rotate
10047 {
10048 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
10049 script_drawing_commands.ReleaseSubBitmap(b);
10050 }
10051 }
10052
10053 4327380 void do_drawlayerr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10054 {
10055 //sdci[1]=layer
10056 //sdci[2]=map
10057 //sdci[3]=screen
10058 //sdci[4]=layer
10059 //sdci[5]=x
10060 //sdci[6]=y
10061 //sdci[7]=rotation
10062 //sdci[8]=opacity
10063
10064 4327380 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10065 4327380 int32_t scrn = sdci[3]/10000;
10066 4327380 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
10067 4327380 int32_t x = sdci[5]/10000;
10068 4327380 int32_t y = sdci[6]/10000;
10069 4327380 int32_t x1 = x + xoffset;
10070 4327380 int32_t y1 = y + yoffset;
10071 4327380 int32_t rotation = sdci[7]/10000;
10072 4327380 int32_t opacity = sdci[8]/10000;
10073
10074 4327380 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
10075 4327380 const mapscr* m = getmapscreen(map, scrn, sourceLayer);
10076
10077
2/2
✓ Branch 0 taken 4290659 times.
✓ Branch 1 taken 36721 times.
4327380 if(!m) //no need to log it.
10078 36721 return;
10079
10080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4290659 times.
4290659 if(index >= TheMaps.size())
10081 {
10082 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
10083 return;
10084 }
10085
10086 4290659 const mapscr & l = *m;
10087
10088 4290659 BITMAP* b = bmp;
10089
10090
1/2
✓ Branch 0 taken 4290659 times.
✗ Branch 1 not taken.
4290659 if(rotation != 0)
10091 b = script_drawing_commands.AquireSubBitmap(256, 176);
10092
10093
10094 4290659 const int32_t maxX = isOffScreen ? 512 : 256;
10095
2/2
✓ Branch 0 taken 4280939 times.
✓ Branch 1 taken 9720 times.
4290659 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
10096 4290659 bool transparent = opacity <= 128;
10097
10098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4290659 times.
4290659 if(rotation != 0) // rotate
10099 {
10100 draw_mapscr(b, l, x1, y1, transparent);
10101
10102 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
10103 script_drawing_commands.ReleaseSubBitmap(b);
10104 }
10105 else
10106 {
10107
2/2
✓ Branch 0 taken 755155984 times.
✓ Branch 1 taken 4290659 times.
759446643 for(int32_t i(0); i < 176; ++i)
10108 {
10109 755155984 const int32_t x2 = ((i&15)<<4) + x1;
10110 755155984 const int32_t y2 = (i&0xF0) + y1;
10111
10112
7/8
✓ Branch 0 taken 664651350 times.
✓ Branch 1 taken 90504634 times.
✓ Branch 2 taken 664651350 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 610245958 times.
✓ Branch 5 taken 54405392 times.
✓ Branch 6 taken 9155742 times.
✓ Branch 7 taken 601090216 times.
755155984 if(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY) //in clipping rect
10113 {
10114 601090216 const newcombo & c = combobuf[ l.data[i] ];
10115 601090216 const int32_t tile = combo_tile(c, x2, y2);
10116
10117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 601090216 times.
601090216 if(opacity < 128)
10118 {
10119 overcomboblocktranslucent(b, x2, y2, l.data[i], l.cset[i], 1, 1, 128);
10120
10121
10122 //overtiletranslucent16(b, tile, x2, y2, l.cset[i], c.flip, opacity);
10123 }
10124 else
10125 {
10126 601090216 overcomboblock(b, x2, y2, l.data[i], l.cset[i], 1, 1);
10127 //overtile16(b, tile, x2, y2, l.cset[i], c.flip);
10128 }
10129 //putcombo( b, xx, yy, l.data[i], l.cset[i] );
10130 601090216 }
10131 755155984 }
10132 }
10133
10134 //putscr
10135 4327380 }
10136
10137
10138
10139 50103 void do_drawscreenr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10140 {
10141 //sdci[1]=layer
10142 //sdci[2]=map
10143 //sdci[3]=screen
10144 //sdci[4]=x
10145 //sdci[5]=y
10146 //sdci[6]=rotation
10147
10148 50103 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10149 50103 int32_t scrn = sdci[3]/10000;
10150 50103 int32_t x = sdci[4]/10000;
10151 50103 int32_t y = sdci[5]/10000;
10152 50103 int32_t x1 = x + xoffset;
10153 50103 int32_t y1 = y + yoffset;
10154 50103 int32_t rotation = sdci[6]/10000;
10155
10156 50103 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
10157
10158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50103 times.
50103 if(index >= TheMaps.size())
10159 {
10160 al_trace("DrawScreen: invalid map or screen index. \n");
10161 return;
10162 }
10163
10164 50103 const mapscr & m = TheMaps[index];
10165
10166
10167 50103 BITMAP* b = bmp;
10168
10169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50103 times.
50103 if(rotation != 0)
10170 b = script_drawing_commands.AquireSubBitmap(256, 176);
10171
10172 //draw layer 0
10173 50103 draw_mapscr(b, m, x1, y1, false);
10174
10175
2/2
✓ Branch 0 taken 50103 times.
✓ Branch 1 taken 300618 times.
350721 for(int32_t i(0); i < 6; ++i)
10176 {
10177
2/2
✓ Branch 0 taken 137944 times.
✓ Branch 1 taken 162674 times.
300618 if(m.layermap[i] == 0) continue;
10178
10179 137944 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
10180
10181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137944 times.
137944 if(layer_screen_index >= TheMaps.size())
10182 continue;
10183
10184 137944 bool trans = m.layeropacity[i] == 128;
10185
10186 //draw valid layers
10187 137944 draw_mapscr(b, TheMaps[ layer_screen_index ], x1, y1, trans);
10188 137944 }
10189
10190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50103 times.
50103 if(rotation != 0) // rotate
10191 {
10192 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
10193 script_drawing_commands.ReleaseSubBitmap(b);
10194 }
10195 50103 }
10196
10197
10198 1173 void do_bmpdrawlayerr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10199 {
10200 //sdci[1]=layer
10201 //sdci[2]=map
10202 //sdci[3]=screen
10203 //sdci[4]=layer
10204 //sdci[5]=x
10205 //sdci[6]=y
10206 //sdci[7]=rotation
10207 //[8] noclip
10208 //sdci[9]=opacity
10209 //sdci[17] Bitmap Pointer
10210
10211 1173 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
10212
1/2
✓ Branch 0 taken 1173 times.
✗ Branch 1 not taken.
1173 if ( refbmp == NULL ) return;
10213
10214 1173 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10215 1173 int32_t scrn = sdci[3]/10000;
10216 1173 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
10217 1173 int32_t x = sdci[5]/10000;
10218 1173 int32_t y = sdci[6]/10000;
10219 1173 int32_t rotation = sdci[7]/10000;
10220
10221 1173 byte noclip = 0;//(sdci[8]!=0);
10222 1173 int32_t opacity = sdci[8]/10000;
10223 //zprint2("Running bmp->DrawLayer(%d, %d, %d, %d, %d, %d, %d, %d)\n", sdci[1]/10000, map, scrn, sourceLayer, x, y, rotation, opacity);
10224 1173 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
10225 1173 const mapscr* m = getmapscreen(map, scrn, sourceLayer);
10226
10227
2/2
✓ Branch 0 taken 1167 times.
✓ Branch 1 taken 6 times.
1173 if(!m) //no need to log it.
10228 6 return;
10229
10230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1167 times.
1167 if(index >= TheMaps.size())
10231 {
10232 Z_scripterrlog("DrawLayer: invalid map index \"%i\". Map count is %d.\n", index, TheMaps.size());
10233 return;
10234 }
10235
10236 1167 const mapscr & l = *m;
10237
10238 1167 BITMAP* b = FFCore.GetScriptBitmap(sdci[17]-10);
10239
1/2
✓ Branch 0 taken 1167 times.
✗ Branch 1 not taken.
1167 if ( refbmp == NULL ) return;
10240
2/4
✓ Branch 0 taken 1167 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1167 times.
✗ Branch 3 not taken.
1167 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
10241
1/2
✓ Branch 0 taken 1167 times.
✗ Branch 1 not taken.
1167 if(rotation != 0)
10242 b = script_drawing_commands.AquireSubBitmap(256, 176);
10243
10244
10245 1167 const int32_t maxX = isOffScreen ? 512 : 256;
10246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1167 times.
1167 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
10247 1167 bool transparent = opacity <= 128;
10248
10249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1167 times.
1167 if(rotation != 0) // rotate
10250 {
10251 draw_mapscr(b, l, x, y, transparent);
10252
10253 rotate_sprite(refbmp, b, x, y, degrees_to_fixed(rotation));
10254 script_drawing_commands.ReleaseSubBitmap(b);
10255 }
10256 else
10257 {
10258
2/2
✓ Branch 0 taken 205392 times.
✓ Branch 1 taken 1167 times.
206559 for(int32_t i(0); i < 176; ++i)
10259 {
10260 205392 const int32_t x2 = ((i&15)<<4) + x;
10261 205392 const int32_t y2 = (i&0xF0) + y;
10262
10263 //if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
10264 {
10265 205392 const newcombo & c = combobuf[ l.data[i] ];
10266 205392 const int32_t tile = combo_tile(c, x2, y2);
10267
10268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205392 times.
205392 if(opacity < 128)
10269 overtiletranslucent16(refbmp, tile, x2, y2, l.cset[i], c.flip, opacity);
10270 else
10271 205392 overtile16(refbmp, tile, x2, y2, l.cset[i], c.flip);
10272
10273 //putcombo( b, xx, yy, l.data[i], l.cset[i] );
10274 }
10275 205392 }
10276 }
10277
10278 //putscr
10279 1173 }
10280
10281
10282
10283 1092 void do_bmpdrawscreenr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10284 {
10285 //sdci[1]=layer
10286 //sdci[2]=map
10287 //sdci[3]=screen
10288 //sdci[4]=x
10289 //sdci[5]=y
10290 //sdci[6]=rotation
10291 //sdci[17] Bitmap Pointer
10292
10293 1092 BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10);
10294
1/2
✓ Branch 0 taken 1092 times.
✗ Branch 1 not taken.
1092 if ( refbmp == NULL ) return;
10295
10296
2/4
✓ Branch 0 taken 1092 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1092 times.
1092 if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop.
10297
10298 1092 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10299 1092 int32_t scrn = sdci[3]/10000;
10300 1092 int32_t x = sdci[4]/10000;
10301 1092 int32_t y = sdci[5]/10000;
10302 1092 int32_t x1 = x + xoffset;
10303 1092 int32_t y1 = y + yoffset;
10304 1092 int32_t rotation = sdci[6]/10000;
10305
10306 1092 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
10307
10308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1092 times.
1092 if(index >= TheMaps.size())
10309 {
10310 al_trace("DrawScreen: invalid map or screen index. \n");
10311 return;
10312 }
10313
10314 1092 const mapscr & m = TheMaps[index];
10315
10316
10317 1092 BITMAP* b = FFCore.GetScriptBitmap(sdci[17]-10);
10318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1092 times.
1092 if ( refbmp == NULL ) return;
10319
10320
1/2
✓ Branch 0 taken 1092 times.
✗ Branch 1 not taken.
1092 if(rotation != 0)
10321 b = script_drawing_commands.AquireSubBitmap(256, 176);
10322
10323 //draw layer 0
10324 1092 draw_mapscr(b, m, x1, y1, false);
10325
10326
2/2
✓ Branch 0 taken 1092 times.
✓ Branch 1 taken 6552 times.
7644 for(int32_t i(0); i < 6; ++i)
10327 {
10328
2/2
✓ Branch 0 taken 2118 times.
✓ Branch 1 taken 4434 times.
6552 if(m.layermap[i] == 0) continue;
10329
10330 2118 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
10331
10332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2118 times.
2118 if(layer_screen_index >= TheMaps.size())
10333 continue;
10334
10335 2118 bool trans = m.layeropacity[i] == 128;
10336
10337 //draw valid layers
10338 2118 draw_mapscr(b, TheMaps[ layer_screen_index ], x1, y1, trans);
10339 2118 }
10340
10341
1/2
✓ Branch 0 taken 1092 times.
✗ Branch 1 not taken.
1092 if(rotation != 0) // rotate
10342 {
10343 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
10344 script_drawing_commands.ReleaseSubBitmap(b);
10345 }
10346 1092 }
10347
10348 void do_bmpdrawlayersolidmaskr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10349 {
10350 //sdci[1]=layer
10351 //sdci[2]=map
10352 //sdci[3]=screen
10353 //sdci[4]=layer
10354 //sdci[5]=x
10355 //sdci[6]=y
10356 //sdci[7]=rotation
10357 //sdci[8]=bool noclip
10358 //sdci[9] == opacity
10359
10360 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10361 int32_t scrn = sdci[3]/10000;
10362 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
10363 int32_t x = sdci[5]/10000;
10364 int32_t y = sdci[6]/10000;
10365 int32_t x1 = x + xoffset;
10366 int32_t y1 = y + yoffset;
10367 int32_t rotation = sdci[7]/10000;
10368 byte noclip = (sdci[8]!=0);
10369 int32_t opacity = sdci[9]/10000;
10370
10371 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
10372 const mapscr* m = getmapscreen(map, scrn, sourceLayer);
10373
10374 if(!m) //no need to log it.
10375 return;
10376
10377 if(index >= TheMaps.size())
10378 {
10379 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
10380 return;
10381 }
10382
10383 const mapscr & l = *m;
10384
10385 BITMAP* b = bmp;
10386
10387 if(rotation != 0)
10388 b = script_drawing_commands.AquireSubBitmap(256, 176);
10389
10390
10391 const int32_t maxX = isOffScreen ? 512 : 256;
10392 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
10393 bool transparent = opacity <= 128;
10394
10395 if(rotation != 0) // rotate
10396 {
10397 draw_map_solid(b, l, x1, y1);
10398
10399 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
10400 script_drawing_commands.ReleaseSubBitmap(b);
10401 }
10402 else
10403 {
10404 BITMAP* square = create_bitmap_ex(8,16,16);
10405 BITMAP* subsquare = create_bitmap_ex(8,16,16);
10406 clear_to_color(subsquare,1);
10407 for(int32_t i(0); i < 176; ++i)
10408 {
10409 const int32_t x2 = ((i&15)<<4) + x1;
10410 const int32_t y2 = (i&0xF0) + y1;
10411
10412 if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
10413 {
10414 int32_t sol = (combobuf[l.data[i]].walk);
10415
10416 if ( sol & 1 )
10417 {
10418 blit(subsquare, square, 0, 0, 0, 0, 8, 8);
10419 }
10420 if ( sol & 2 )
10421 {
10422 blit(subsquare, square, 0, 0, 0, 8, 8, 8);
10423 }
10424 if ( sol & 4 )
10425 {
10426 blit(subsquare, square, 0, 0, 8, 0, 8, 8);
10427 }
10428 if ( sol &8 ) {
10429 blit(subsquare, square, 0, 0, 8, 8, 8, 8);
10430 }
10431
10432 blit(square, b, 0, 0, x2, y2, square->w, square->h);
10433 }
10434 }
10435 destroy_bitmap(square);
10436 destroy_bitmap(subsquare);
10437 }
10438
10439 //putscr
10440 }
10441
10442 void do_bmpdrawlayersolidityr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10443 {
10444 //sdci[1]=layer
10445 //sdci[2]=map
10446 //sdci[3]=screen
10447 //sdci[4]=layer
10448 //sdci[5]=x
10449 //sdci[6]=y
10450 //sdci[7]=rotation
10451 //[8] noclip
10452 //sdci[9]=opacity
10453
10454
10455 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10456 int32_t scrn = sdci[3]/10000;
10457 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
10458 int32_t x = sdci[5]/10000;
10459 int32_t y = sdci[6]/10000;
10460 int32_t x1 = x + xoffset;
10461 int32_t y1 = y + yoffset;
10462 int32_t rotation = sdci[7]/10000;
10463 byte noclip = (sdci[8]!=0);
10464 int32_t opacity = sdci[9]/10000;
10465
10466 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
10467 const mapscr* m = getmapscreen(map, scrn, sourceLayer);
10468
10469 if(!m) //no need to log it.
10470 return;
10471
10472 if(index >= TheMaps.size())
10473 {
10474 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
10475 return;
10476 }
10477
10478 const mapscr & l = *m;
10479
10480 BITMAP* b = bmp;
10481
10482 if(rotation != 0)
10483 b = script_drawing_commands.AquireSubBitmap(256, 176);
10484
10485
10486 const int32_t maxX = isOffScreen ? 512 : 256;
10487 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
10488 bool transparent = opacity <= 128;
10489
10490 if(rotation != 0) // rotate
10491 {
10492 draw_map_solidity(b, l, x1, y1);
10493
10494 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
10495 script_drawing_commands.ReleaseSubBitmap(b);
10496 }
10497 else
10498 {
10499 BITMAP* square = create_bitmap_ex(8,16,16);
10500 for(int32_t i(0); i < 176; ++i)
10501 {
10502 const int32_t x2 = ((i&15)<<4) + x1;
10503 const int32_t y2 = (i&0xF0) + y1;
10504
10505 if(noclip && (x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
10506 {
10507 clear_to_color(square,(combobuf[l.data[i]].walk&15));
10508 blit(square, b, 0, 0, x2, y2, square->w, square->h);
10509 }
10510 }
10511 destroy_bitmap(square);
10512 }
10513
10514 //putscr
10515 }
10516
10517 void do_bmpdrawlayercflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10518 {
10519 //sdci[1]=layer
10520 //sdci[2]=map
10521 //sdci[3]=screen
10522 //sdci[4]=layer
10523 //sdci[5]=x
10524 //sdci[6]=y
10525 //sdci[7]=rotation
10526 //[8] noclip
10527 //sdci[9]=opacity
10528
10529
10530 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10531 int32_t scrn = sdci[3]/10000;
10532 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
10533 int32_t x = sdci[5]/10000;
10534 int32_t y = sdci[6]/10000;
10535 int32_t x1 = x + xoffset;
10536 int32_t y1 = y + yoffset;
10537 int32_t rotation = sdci[7]/10000;
10538
10539 byte noclip = (sdci[8]!=0);
10540 int32_t opacity = sdci[9]/10000;
10541
10542 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
10543 const mapscr* m = getmapscreen(map, scrn, sourceLayer);
10544
10545 if(!m) //no need to log it.
10546 return;
10547
10548 if(index >= TheMaps.size())
10549 {
10550 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
10551 return;
10552 }
10553
10554 const mapscr & l = *m;
10555
10556 BITMAP* b = bmp;
10557
10558 if(rotation != 0)
10559 b = script_drawing_commands.AquireSubBitmap(256, 176);
10560
10561
10562 const int32_t maxX = isOffScreen ? 512 : 256;
10563 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
10564 bool transparent = opacity <= 128;
10565
10566 if(rotation != 0) // rotate
10567 {
10568 draw_map_cflag(b, l, x1, y1);
10569
10570 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
10571 script_drawing_commands.ReleaseSubBitmap(b);
10572 }
10573 else
10574 {
10575 BITMAP* square = create_bitmap_ex(8,16,16);
10576 for(int32_t i(0); i < 176; ++i)
10577 {
10578 const int32_t x2 = ((i&15)<<4) + x1;
10579 const int32_t y2 = (i&0xF0) + y1;
10580
10581 if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
10582 {
10583 clear_to_color(square,l.sflag[i]);
10584 blit(square, b, 0, 0, x2, y2, square->w, square->h);
10585 }
10586 }
10587 destroy_bitmap(square);
10588 }
10589
10590 //putscr
10591 }
10592
10593 void do_bmpdrawlayerctyper(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10594 {
10595 //sdci[1]=layer
10596 //sdci[2]=map
10597 //sdci[3]=screen
10598 //sdci[4]=layer
10599 //sdci[5]=x
10600 //sdci[6]=y
10601 //sdci[7]=rotation
10602 //[8] noclip
10603 //sdci[9]=opacity
10604
10605 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10606 int32_t scrn = sdci[3]/10000;
10607 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
10608 int32_t x = sdci[5]/10000;
10609 int32_t y = sdci[6]/10000;
10610 int32_t x1 = x + xoffset;
10611 int32_t y1 = y + yoffset;
10612 int32_t rotation = sdci[7]/10000;
10613
10614 byte noclip = (sdci[8]!=0);
10615 int32_t opacity = sdci[9]/10000;
10616 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
10617 const mapscr* m = getmapscreen(map, scrn, sourceLayer);
10618
10619 if(!m) //no need to log it.
10620 return;
10621
10622 if(index >= TheMaps.size())
10623 {
10624 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
10625 return;
10626 }
10627
10628 const mapscr & l = *m;
10629
10630 BITMAP* b = bmp;
10631
10632 if(rotation != 0)
10633 b = script_drawing_commands.AquireSubBitmap(256, 176);
10634
10635
10636 const int32_t maxX = isOffScreen ? 512 : 256;
10637 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
10638 bool transparent = opacity <= 128;
10639
10640 if(rotation != 0) // rotate
10641 {
10642 draw_map_combotype(b, l, x1, y1);
10643
10644 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
10645 script_drawing_commands.ReleaseSubBitmap(b);
10646 }
10647 else
10648 {
10649 BITMAP* square = create_bitmap_ex(8,16,16);
10650 for(int32_t i(0); i < 176; ++i)
10651 {
10652 const int32_t x2 = ((i&15)<<4) + x1;
10653 const int32_t y2 = (i&0xF0) + y1;
10654
10655 if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
10656 {
10657 clear_to_color(square,(combobuf[l.data[i]].type));
10658 blit(square, b, 0, 0, x2, y2, square->w, square->h);
10659 }
10660 }
10661 destroy_bitmap(square);
10662 }
10663
10664 //putscr
10665 }
10666
10667 void do_bmpdrawlayerciflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10668 {
10669 //sdci[1]=layer
10670 //sdci[2]=map
10671 //sdci[3]=screen
10672 //sdci[4]=layer
10673 //sdci[5]=x
10674 //sdci[6]=y
10675 //sdci[7]=rotation
10676 //[8] noclip
10677 //sdci[9]=opacity
10678
10679 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10680 int32_t scrn = sdci[3]/10000;
10681 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
10682 int32_t x = sdci[5]/10000;
10683 int32_t y = sdci[6]/10000;
10684 int32_t x1 = x + xoffset;
10685 int32_t y1 = y + yoffset;
10686 int32_t rotation = sdci[7]/10000;
10687 byte noclip = (sdci[8]!=0);
10688 int32_t opacity = sdci[9]/10000;
10689
10690 const uint32_t index = (uint32_t)(map * MAPSCRS + scrn);
10691 const mapscr* m = getmapscreen(map, scrn, sourceLayer);
10692
10693 if(!m) //no need to log it.
10694 return;
10695
10696 if(index >= TheMaps.size())
10697 {
10698 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
10699 return;
10700 }
10701
10702 const mapscr & l = *m;
10703
10704 BITMAP* b = bmp;
10705
10706 if(rotation != 0)
10707 b = script_drawing_commands.AquireSubBitmap(256, 176);
10708
10709
10710 const int32_t maxX = isOffScreen ? 512 : 256;
10711 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
10712 bool transparent = opacity <= 128;
10713
10714 if(rotation != 0) // rotate
10715 {
10716 draw_map_comboiflag(b, l, x1, y1);
10717
10718 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
10719 script_drawing_commands.ReleaseSubBitmap(b);
10720 }
10721 else
10722 {
10723 BITMAP* square = create_bitmap_ex(8,16,16);
10724 for(int32_t i(0); i < 176; ++i)
10725 {
10726 const int32_t x2 = ((i&15)<<4) + x1;
10727 const int32_t y2 = (i&0xF0) + y1;
10728
10729 if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
10730 {
10731 clear_to_color(square,(combobuf[l.data[i]].flag));
10732 blit(square, b, 0, 0, x2, y2, square->w, square->h);
10733 }
10734 }
10735 destroy_bitmap(square);
10736 }
10737
10738 //putscr
10739 }
10740
10741
10742
10743 /////////////////////////////////////////////////////////
10744 // do primitives
10745 ////////////////////////////////////////////////////////
10746
10747 201340823 void do_primitives(BITMAP *targetBitmap, int32_t type, mapscr* theScreen, int32_t xoff, int32_t yoff)
10748 {
10749 201340823 color_map = &trans_table2;
10750
10751 //was this next variable ever used? -- DN
10752 //bool drawsubscr=false;
10753
10754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201340823 times.
201340823 if(type > 7)
10755 return;
10756
3/4
✓ Branch 0 taken 62185880 times.
✓ Branch 1 taken 139154943 times.
✓ Branch 2 taken 62185880 times.
✗ Branch 3 not taken.
201340823 if(type >= 0 && theScreen->hidescriptlayers & (1<<type))
10757 return; //Script draws hidden for this layer
10758
2/2
✓ Branch 0 taken 1934273 times.
✓ Branch 1 taken 199406550 times.
201340823 if(!script_drawing_commands.is_dirty(type))
10759 199406550 return; //No draws to this layer
10760 //--script_drawing_commands[][] reference--
10761 //[][0]: type
10762 //[][1-16]: defined by type
10763 //[][17]: unused
10764 //[][18]: rendertarget
10765 //[][19]: unused
10766
10767 // Trying to match the old behavior exactly...
10768
2/2
✓ Branch 0 taken 545426 times.
✓ Branch 1 taken 1388847 times.
1934273 const bool brokenOffset= ( (get_er(er_BITMAPOFFSET)!=0) || (get_qr(qr_BITMAPOFFSETFIX)!=0) );
10769
10770 1934273 bool isTargetOffScreenBmp = false;
10771 1934273 const int32_t type_mul_10000 = type * 10000;
10772 1934273 const int32_t numDrawCommandsToProcess = script_drawing_commands.Count();
10773 1934273 FFCore.numscriptdraws = numDrawCommandsToProcess;
10774 1934273 int32_t xoffset=xoff, yoffset=yoff;
10775
2/2
✓ Branch 0 taken 95892401 times.
✓ Branch 1 taken 1934273 times.
97826674 for(int32_t i(0); i < numDrawCommandsToProcess; ++i)
10776 {
10777
2/2
✓ Branch 0 taken 13986680 times.
✓ Branch 1 taken 81905721 times.
95892401 if(!brokenOffset)
10778 {
10779 81905721 xoffset = 0;
10780 81905721 yoffset = 0;
10781 81905721 }
10782 95892401 int32_t *sdci = &script_drawing_commands[i][0];
10783
10784
2/2
✓ Branch 0 taken 56582879 times.
✓ Branch 1 taken 39309522 times.
95892401 if(sdci[1] != type_mul_10000)
10785 56582879 continue;
10786 // get the correct render target, if set.
10787 39309522 BITMAP *bmp = zscriptDrawingRenderTarget->GetTargetBitmap(sdci[18]);
10788
10789
2/2
✓ Branch 0 taken 6385290 times.
✓ Branch 1 taken 32924232 times.
39309522 if(!bmp)
10790 {
10791 // draw to screen with subscreen offset
10792
2/2
✓ Branch 0 taken 6901786 times.
✓ Branch 1 taken 26022446 times.
32924232 if(!brokenOffset)
10793 {
10794 26022446 xoffset = xoff;
10795 26022446 yoffset = yoff;
10796 26022446 }
10797 32924232 bmp = targetBitmap;
10798 32924232 }
10799 else
10800 {
10801 //not drawing to screen, so no subscreen offset
10802
2/2
✓ Branch 0 taken 6301923 times.
✓ Branch 1 taken 83367 times.
6385290 if(brokenOffset)
10803 {
10804 83367 xoffset = 0;
10805 83367 yoffset = 0;
10806 83367 }
10807 6385290 isTargetOffScreenBmp = true;
10808 }
10809
10810
37/82
✗ Branch 0 not taken.
✓ Branch 1 taken 2290034 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1130854 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1850 times.
✓ Branch 6 taken 937839 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 404879 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 866805 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 1742823 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 4910510 times.
✓ Branch 18 taken 18675043 times.
✓ Branch 19 taken 936091 times.
✓ Branch 20 taken 97816 times.
✓ Branch 21 taken 1263883 times.
✓ Branch 22 taken 153213 times.
✓ Branch 23 taken 9266 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 834978 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 4327380 times.
✓ Branch 31 taken 50103 times.
✓ Branch 32 taken 7818 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 1480 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 502 times.
✓ Branch 37 taken 144 times.
✗ Branch 38 not taken.
✓ Branch 39 taken 80910 times.
✓ Branch 40 taken 59428 times.
✗ Branch 41 not taken.
✓ Branch 42 taken 824 times.
✗ Branch 43 not taken.
✓ Branch 44 taken 167316 times.
✓ Branch 45 taken 784 times.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✓ Branch 49 taken 45504 times.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✓ Branch 56 taken 1173 times.
✓ Branch 57 taken 1092 times.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✓ Branch 60 taken 1024 times.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✓ Branch 63 taken 236166 times.
✗ Branch 64 not taken.
✓ Branch 65 taken 909 times.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✓ Branch 68 taken 26369 times.
✓ Branch 69 taken 2790 times.
✓ Branch 70 taken 34653 times.
✗ Branch 71 not taken.
✗ Branch 72 not taken.
✗ Branch 73 not taken.
✗ Branch 74 not taken.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✓ Branch 78 taken 6363 times.
✗ Branch 79 not taken.
✓ Branch 80 taken 906 times.
✗ Branch 81 not taken.
39309522 switch(sdci[0])
10811 {
10812 case RECTR:
10813 {
10814 2290034 do_rectr(bmp, sdci, xoffset, yoffset);
10815 }
10816 2290034 break;
10817 case FRAMER:
10818 {
10819 do_framer(bmp, sdci, xoffset, yoffset);
10820 }
10821 break;
10822
10823
10824 case CIRCLER:
10825 {
10826 1130854 do_circler(bmp, sdci, xoffset, yoffset);
10827 }
10828 1130854 break;
10829
10830 case ARCR:
10831 {
10832 do_arcr(bmp, sdci, xoffset, yoffset);
10833 }
10834 break;
10835
10836 case ELLIPSER:
10837 {
10838 1850 do_ellipser(bmp, sdci, xoffset, yoffset);
10839 }
10840 1850 break;
10841
10842 case LINER:
10843 {
10844 937839 do_liner(bmp, sdci, xoffset, yoffset);
10845 }
10846 937839 break;
10847
10848 case SPLINER:
10849 {
10850 do_spliner(bmp, sdci, xoffset, yoffset);
10851 }
10852 break;
10853
10854 case PUTPIXELR:
10855 {
10856 404879 do_putpixelr(bmp, sdci, xoffset, yoffset);
10857 }
10858 404879 break;
10859 case PIXELARRAYR:
10860 {
10861 //Z_scripterrlog("Reached case PIXELARRAYR\n");
10862 do_putpixelsr(bmp, i, sdci, xoffset, yoffset);
10863 }
10864 break;
10865
10866 case TILEARRAYR:
10867 {
10868 //Z_scripterrlog("Reached case PIXELARRAYR\n");
10869 do_fasttilesr(bmp, i, sdci, xoffset, yoffset);
10870 }
10871 break;
10872
10873 case LINESARRAY:
10874 {
10875 //Z_scripterrlog("Reached case PIXELARRAYR\n");
10876 do_linesr(bmp, i, sdci, xoffset, yoffset);
10877 }
10878 break;
10879
10880 case COMBOARRAYR:
10881 {
10882 //Z_scripterrlog("Reached case PIXELARRAYR\n");
10883 do_fastcombosr(bmp, i, sdci, xoffset, yoffset);
10884 }
10885 break;
10886
10887
10888
10889 case DRAWTILER:
10890 {
10891 866805 do_drawtiler(bmp, sdci, xoffset, yoffset);
10892 }
10893 866805 break;
10894
10895 case DRAWTILECLOAKEDR:
10896 {
10897 do_drawtilecloakedr(bmp, sdci, xoffset, yoffset);
10898 }
10899 break;
10900
10901 case DRAWCOMBOR:
10902 {
10903 1742823 do_drawcombor(bmp, sdci, xoffset, yoffset);
10904 }
10905 1742823 break;
10906
10907 case DRAWCOMBOCLOAKEDR:
10908 {
10909 do_drawcombocloakedr(bmp, sdci, xoffset, yoffset);
10910 }
10911 break;
10912
10913 case FASTTILER:
10914 {
10915 4910510 do_fasttiler(bmp, sdci, xoffset, yoffset);
10916 }
10917 4910510 break;
10918
10919 case FASTCOMBOR:
10920 {
10921 18675043 do_fastcombor(bmp, sdci, xoffset, yoffset);
10922 }
10923 18675043 break;
10924
10925 case DRAWCHARR:
10926 {
10927 936091 do_drawcharr(bmp, sdci, xoffset, yoffset);
10928 }
10929 936091 break;
10930
10931 case DRAWINTR:
10932 {
10933 97816 do_drawintr(bmp, sdci, xoffset, yoffset);
10934 }
10935 97816 break;
10936
10937 case DRAWSTRINGR:
10938 {
10939 1263883 do_drawstringr(bmp, i, sdci, xoffset, yoffset);
10940 }
10941 1263883 break;
10942
10943 case DRAWSTRINGR2:
10944 {
10945 153213 do_drawstringr2(bmp, i, sdci, xoffset, yoffset);
10946 }
10947 153213 break;
10948
10949 case QUADR:
10950 {
10951 9266 do_drawquadr(bmp, sdci, xoffset, yoffset);
10952 }
10953 9266 break;
10954
10955 case QUAD3DR:
10956 {
10957 do_drawquad3dr(bmp, i, sdci, xoffset, yoffset);
10958 }
10959 break;
10960
10961 case TRIANGLER:
10962 {
10963 do_drawtriangler(bmp, sdci, xoffset, yoffset);
10964 }
10965 break;
10966
10967 case TRIANGLE3DR:
10968 {
10969 do_drawtriangle3dr(bmp, i, sdci, xoffset, yoffset);
10970 }
10971 break;
10972
10973 case POLYGONR:
10974 {
10975 do_polygonr(bmp, i, sdci, xoffset, yoffset);
10976 }
10977 break;
10978
10979
10980 case BITMAPR:
10981 {
10982 834978 do_drawbitmapr(bmp, sdci, xoffset, yoffset);
10983 }
10984 834978 break;
10985
10986 case BITMAPEXR:
10987 {
10988 do_drawbitmapexr(bmp, sdci, xoffset, yoffset);
10989 }
10990 break;
10991
10992 case DRAWLAYERR:
10993 {
10994 4327380 do_drawlayerr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp);
10995 }
10996 4327380 break;
10997
10998 case DRAWSCREENR:
10999 {
11000 50103 do_drawscreenr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp);
11001 }
11002 50103 break;
11003
11004 7818 case BMPRECTR: bmp_do_rectr(bmp, sdci, xoffset, yoffset); break;
11005 case BMPFRAMER: bmp_do_framer(bmp, sdci, xoffset, yoffset); break;
11006 1480 case BMPCIRCLER: bmp_do_circler(bmp, sdci, xoffset, yoffset); break;
11007 case BMPARCR: bmp_do_arcr(bmp, sdci, xoffset, yoffset); break;
11008 502 case BMPELLIPSER: bmp_do_ellipser(bmp, sdci, xoffset, yoffset); break;
11009 144 case BMPLINER: bmp_do_liner(bmp, sdci, xoffset, yoffset); break;
11010 case BMPSPLINER: bmp_do_spliner(bmp, sdci, xoffset, yoffset); break;
11011 80910 case BMPPUTPIXELR: bmp_do_putpixelr(bmp, sdci, xoffset, yoffset); break;
11012 59428 case BMPDRAWTILER: bmp_do_drawtiler(bmp, sdci, xoffset, yoffset); break;
11013 case BMPDRAWTILECLOAKEDR: bmp_do_drawtilecloakedr(bmp, sdci, xoffset, yoffset); break;
11014 824 case BMPDRAWCOMBOR: bmp_do_drawcombor(bmp, sdci, xoffset, yoffset); break;
11015 case BMPDRAWCOMBOCLOAKEDR: bmp_do_drawcombocloakedr(bmp, sdci, xoffset, yoffset); break;
11016 167316 case BMPFASTTILER: bmp_do_fasttiler(bmp, sdci, xoffset, yoffset); break;
11017 784 case BMPFASTCOMBOR: bmp_do_fastcombor(bmp, sdci, xoffset, yoffset); break;
11018 case BMPDRAWCHARR: bmp_do_drawcharr(bmp, sdci, xoffset, yoffset); break;
11019 case BMPDRAWINTR: bmp_do_drawintr(bmp, sdci, xoffset, yoffset); break;
11020 case BMPDRAWSTRINGR: bmp_do_drawstringr(bmp, i, sdci, xoffset, yoffset); break;
11021 45504 case BMPDRAWSTRINGR2: bmp_do_drawstringr2(bmp, i, sdci, xoffset, yoffset); break;
11022 case BMPQUADR: bmp_do_drawquadr(bmp, sdci, xoffset, yoffset); break;
11023 case BMPQUAD3DR: bmp_do_drawquad3dr(bmp, i, sdci, xoffset, yoffset); break;
11024
11025 case BITMAPGETPIXEL: bmp_do_getpixelr(bmp, sdci, xoffset, yoffset); break;
11026 case BMPTRIANGLER: bmp_do_drawtriangler(bmp, sdci, xoffset, yoffset); break;
11027 case BMPTRIANGLE3DR: bmp_do_drawtriangle3dr(bmp, i, sdci, xoffset, yoffset); break;
11028 case BMPPOLYGONR: bmp_do_polygonr(bmp, i, sdci, xoffset, yoffset); break;
11029 1173 case BMPDRAWLAYERR: do_bmpdrawlayerr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
11030 1092 case BMPDRAWSCREENR: do_bmpdrawscreenr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
11031 case BMPDRAWSCREENSOLIDR: do_bmpdrawscreen_solidmaskr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
11032 case BMPDRAWSCREENSOLID2R: do_bmpdrawscreen_solidr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
11033 1024 case BMPDRAWSCREENCOMBOFR: do_bmpdrawscreen_cflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
11034 case BMPDRAWSCREENCOMBOIR: do_bmpdrawscreen_ciflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
11035 case BMPDRAWSCREENCOMBOTR: do_bmpdrawscreen_ctyper(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
11036 236166 case BMPBLIT: bmp_do_drawbitmapexr(bmp, sdci, xoffset, yoffset); break;
11037 case BMPMODE7: bmp_do_mode7r(bmp, sdci, xoffset, yoffset); break;
11038 909 case BMPBLITTO: bmp_do_blittor(bmp, sdci, xoffset, yoffset); break;
11039 case READBITMAP: bmp_do_readr(bmp, i, sdci, xoffset, yoffset); break;
11040 case WRITEBITMAP: bmp_do_writer(bmp, i, sdci, xoffset, yoffset); break;
11041 26369 case CLEARBITMAP: bmp_do_clearr(bmp, sdci, xoffset, yoffset); break;
11042 2790 case BITMAPCLEARTOCOLOR: bmp_do_clearcolorr(bmp, sdci, xoffset, yoffset); break;
11043 34653 case REGENERATEBITMAP: bmp_do_regenr(bmp, sdci, xoffset, yoffset); break;
11044
11045 case BMPDRAWLAYERSOLIDR: do_bmpdrawlayersolidmaskr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
11046 case BMPDRAWLAYERCFLAGR: do_bmpdrawlayercflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
11047 case BMPDRAWLAYERCTYPER: do_bmpdrawlayerctyper(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
11048 case BMPDRAWLAYERCIFLAGR: do_bmpdrawlayerciflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
11049 case BMPDRAWLAYERSOLIDITYR: do_bmpdrawlayersolidityr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
11050 case BMPWRITETILE: do_bmpwritetile(bmp, sdci, xoffset, yoffset); break;
11051 case BMPDITHER: do_bmpdither(bmp, sdci, xoffset, yoffset); break;
11052 6363 case BMPREPLCOLOR: do_bmpreplcol(bmp, sdci, xoffset, yoffset); break;
11053 case BMPSHIFTCOLOR: do_bmpshiftcol(bmp, sdci, xoffset, yoffset); break;
11054 906 case BMPMASKDRAW: do_bmpmaskdraw(bmp, sdci, xoffset, yoffset); break;
11055 case BMPMASKBLIT: do_bmpmaskblit(bmp, sdci, xoffset, yoffset); break;
11056 }
11057 39309522 }
11058
11059
11060 1934273 color_map=&trans_table;
11061 201340823 }
11062
11063 8127352 void CScriptDrawingCommands::Clear()
11064 {
11065 8127352 scb.update();
11066 8127352 dirty_layers.clear();
11067
2/2
✓ Branch 0 taken 6559275 times.
✓ Branch 1 taken 1568077 times.
8127352 if(commands.empty())
11068 6559275 return;
11069
11070 //only clear what was used.
11071 1568077 memset((void*)&commands[0], 0, count * sizeof(CScriptDrawingCommandVars));
11072 1568077 count = 0;
11073
11074 1568077 draw_container.Clear();
11075 8127352 }
11076 CScriptDrawingCommands* CScriptDrawingCommands::pop_commands()
11077 {
11078 CScriptDrawingCommands* ret = new CScriptDrawingCommands();
11079 if(commands.empty())
11080 return ret;
11081 ret->push_commands(this, false);
11082
11083 memset((void*)&commands[0], 0, count * sizeof(CScriptDrawingCommandVars));
11084 count = 0;
11085
11086 draw_container.Clear();
11087 return ret;
11088 }
11089 void CScriptDrawingCommands::push_commands(CScriptDrawingCommands* other, bool del)
11090 {
11091 commands.insert(commands.end(), other->commands.begin(), other->commands.end());
11092 count += other->count;
11093 if(del) delete other;
11094 }
11095
11096 9180 void do_script_draws(BITMAP *targetBitmap, mapscr* theScreen, int32_t xoff, int32_t yoff, bool hideLayer7)
11097 {
11098
1/2
✓ Branch 0 taken 9180 times.
✗ Branch 1 not taken.
9180 if(XOR(theScreen->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(targetBitmap, 2, theScreen, xoff, yoff);
11099
2/2
✓ Branch 0 taken 8925 times.
✓ Branch 1 taken 255 times.
9180 if(XOR(theScreen->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(targetBitmap, 3, theScreen, xoff, yoff);
11100 9180 do_primitives(targetBitmap, 0, theScreen, xoff, yoff);
11101 9180 do_primitives(targetBitmap, 1, theScreen, xoff, yoff);
11102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9180 times.
9180 if(!XOR(theScreen->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(targetBitmap, 2, theScreen, xoff, yoff);
11103
2/2
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 8925 times.
9180 if(!XOR(theScreen->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(targetBitmap, 3, theScreen, xoff, yoff);
11104 9180 do_primitives(targetBitmap, 4, theScreen, xoff, yoff);
11105 9180 do_primitives(targetBitmap, 5, theScreen, xoff, yoff);
11106 9180 do_primitives(targetBitmap, 6, theScreen, xoff, yoff);
11107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9180 times.
9180 if(!hideLayer7) do_primitives(targetBitmap, 7, theScreen, xoff, yoff);
11108 9180 }
11109